Questions tagged [flux]

An application design paradigm used as a replacement for MVC, pioneered at Facebook by Jing Chen

Flux is an application design paradigm used as a replacement for the more traditional pattern.

It complements React's composable view components by utilizing a unidirectional data flow. It's more of a pattern rather than a formal framework, and you can start using Flux immediately without a lot of new code.


Popular implementations :

1614 questions
14
votes
2 answers

Is it OK to call setState from within shouldComponentUpdate?

In response to a state change, I want to trigger another state change. Is that inherently a bad idea? The specific sort of scenario is that the component is modeled as a state machine that renders different information according to the value of…
osdiab
  • 1,972
  • 3
  • 26
  • 37
13
votes
1 answer

How do I add redirect to react-router dynamically?

I have sign in component, which should be available for unauthenticated users. And right after the authentication this component should become unavailable. var routes = (
stkvtflw
  • 12,092
  • 26
  • 78
  • 155
13
votes
1 answer

How to handle one-to-many relationships in Flux stores

I'm just starting to use flux (with redux for now) and am wondering how relationships are supposed to be handled. For an example we can use Trello that has boards with columns that contains cards. One approach would be to have one store/reducer for…
Vincent P
  • 699
  • 1
  • 7
  • 18
12
votes
2 answers

Why do we need Flux with React?

I don't understand why we need Flux with React as React itself let's us maintain the state of the application. Every component has an initial state and the state can be changed by user actions or any other asynchronous JavaScript. Why is React…
Narayan Prusty
  • 2,501
  • 3
  • 22
  • 41
12
votes
2 answers

How to handle global state data into deeply nested components in Redux?

So say you have a chat aplication with this component structure: ... ...
Dema
  • 6,867
  • 11
  • 40
  • 48
12
votes
3 answers

How to handle nested api calls in flux

I'm creating a simple CRUD app using Facebook's Flux Dispatcher to handle the creation and editing of posts for an English learning site. I currently am dealing with an api that looks like…
joeellis
  • 2,745
  • 7
  • 28
  • 45
12
votes
1 answer

How to deal with relations in Flux?

Imagine something like Quora. [ { type: "question", answers: [ { type: "answer", upvotes: [ { type: "upvote" } /* more upvotes */ ], comments [ { …
Aron Woost
  • 19,268
  • 13
  • 43
  • 51
11
votes
1 answer

Is using ES6 classes in vue/vuex(/flux?) an anti-pattern?

I've been using Vuex, and it's adherence to only altering state through it's mutators or actions makes me think your store should only include as flat an object as you can, with only primitives types. Some threads even prescribe normalising your…
purplelulu
  • 329
  • 3
  • 7
11
votes
2 answers

Typecheck createAction Redux helper

I have Action type defined like this: type Action = { type: 'DO_X' } | { type: 'DO_Y', payload: string } | { type: 'DO_Z', payload: number } It's a union type where each member is a valid action. Now I'd like to create a…
daGrevis
  • 21,014
  • 37
  • 100
  • 139
11
votes
1 answer

ReactJS Flux Utils components

There is interesting article which describes 4 main classes exposed in Flux Utils. Store ReduceStore MapStore (removed from 3.0.0) Container But it's not super clear what should be used for certain situations. There are only 2 examples for…
oleh.meleshko
  • 4,675
  • 2
  • 27
  • 40
11
votes
1 answer

Why use one store per entity in the flux application architecture?

I am using reactjs and the flux architecture in a project I'm working on. I am a bit puzzled by how to break up nested data correctly into stores and why I should split up my data into multiple stores. To explain the problem I'll use this…
Geoffrey De Vylder
  • 3,963
  • 7
  • 36
  • 56
11
votes
2 answers

How to coordinate server error messages between Flux and React?

I've been learning React and Flux over the past few months, and one thing I've not yet dealt with is displaying error messages to users. Specifically, error messages that occur as a result of an ajax http request within a flux action creator method.…
Ryan
  • 7,733
  • 10
  • 61
  • 106
11
votes
3 answers

React Flux implement dispatch chain

i'm trying to use React with Flux architecture and stumbled on one restriction which i can't handle. Problem is as following: There's a store which listens to an event. Event has object id. We need to fetch object if needed and make it selected. If…
nidu
  • 549
  • 2
  • 18
11
votes
2 answers

Passing CSRF token to REACT/FLUX from node

I'm using nodejs and usually pass down csrf token like the following: util.js module.exports.csrf = function csrf(req, res, next){ res.locals.token = req.csrfToken(); next(); }; app.js app.use(csrf()); app.use(util.csrf); and then in…
Saad
  • 26,316
  • 15
  • 48
  • 69
11
votes
3 answers

Asynchronous data loading in flux stores

Say I have a TodoStore. The TodoStore is responsible for keeping my TODO items. Todo items are stored in a database. I want to know what is the recommended way for loading all todo items into the store and how the views should interact with the…
rafalotufo
  • 3,862
  • 4
  • 25
  • 28