Two-way data binding (Angular) vs one-way data flow (React/Flux)

Angular’s two-way data binding It’s made possible by a mechanism that synchronizes the view and the model whenever either change. In Angular, you update a variable and its change detection mechanism will take care of updating the view, and viceversa. What’s the problem? You don’t control the change detection mechanism. I found myself having to … Read more

Can you, or should you use localStorage in Redux’s initial state?

Redux createStore 2nd param is intended for store initialization: createStore(reducer, [initialState], [enhancer]) So you can do something like this: const initialState = { id: localStorage.getItem(‘id’), name: localStorage.getItem(‘name’), loggedInAt: null }; const store = createStore(mainReducer, initialState); Since reducers should be pure functions (i.e. no side effects) and localStorage.setItem is a side effect, you should avoid saving … Read more

react-router : run is not a function

Since the release of React Router v1.0, the run method has been removed, these breaking changes are documented in the upgrade guide. Your code would roughly translate to this: ReactDOM.render(<Router>{routes}</Router>, document.getElementById(‘app’)) https://github.com/rackt/react-router/blob/832c42946c874fe56ffde0066b1088054311cb98/CHANGES.md

React.js – Communicating between sibling components

TLDR: Yes, you should use a props-from-top-to-bottom and change-handlers-from-bottom-to-top approach. But this can get unwieldy in a larger application, so you can use design patterns like Flux or Redux to reduce your complexity. Simple React approach React components receive their “inputs” as props; and they communicate their “output” by calling functions that were passed to … Read more

Flux best practices: Stores dispatching actions, AJAX calls in Web API Utils?

Is it correct/highly advisable to have all of my $.ajax calls inside my Web API Utils? Callbacks call the action creators, passing the data in the process. Yes, you should put all your request into a single entity, i.e. the Web API Utils. They should dispatch the responses so any store can choose to act … Read more

What is the core difference of redux & reflux in using react based application?

Flux, Reflux and Redux (and many other similar libraries) are all different ways to handle transversal data management. Basic React components work fine with parent-children relationships, but when you have to provide and update data from different parts of the app which are not directly connected it can become quickly messy. Those libraries provide stores … Read more

React + Flux and Server-side rendering? (Isomorphic React + Flux)

Take a look at dispatchr and yahoo’s related libraries. Most flux implementations don’t work in node.js because they use singleton stored, dispatchers, and actions, and have no concept of “we’re done” which is required to know when to render to html and respond to the request. Yahoo’s libraries like fetchr and routr get around this … Read more

How to handle complex side-effects in Redux?

When you want complex async dependencies, just use Bacon, Rx, channels, sagas, or another asynchronous abstraction. You can use them with or without Redux. Example with Redux: observeSomething() .flatMap(someTransformation) .filter(someFilter) .map(createActionSomehow) .subscribe(store.dispatch); You can compose your asynchronous actions any way you like—the only important part is that eventually they turn into store.dispatch(action) calls. Redux Thunk … Read more

MVC vs. Flux ? Bidirectional vs. Unidirectional?

Real and Pure MVC is unidirectional. It is clear from the the wikipedia diagram pasted in the question. More than a decade ago, when server side frameworks like Apache Struts implemented a variant of MVC called Model View Presenter (MVP) pattern, they made every request go through controller and every response come back through controller. … Read more

tech