@christianalfoni
A data you use to populate a template
dispatch
- Hold the state
- Expose state by store.getState()
- Update state by store.dispatch(action)
- Add a listener with store.subscribe(listener)
Following examples are inspired from http://mae.chab.in/archives/2885
// Create initial state
const initialState = {
value: null,
};
const store = createStore(reducer, initialState);
// Initiate action
store.dispatch({type: 'SOME_ACTION', value: 'EX_VALUE'});
// Called once there is change in state
store.subscribe(() => {
// Do something
});
// Reducer
formReducer(state, action) => {
switch (action.type) {
case SOME_ACTION:
return Object.assign({}, state, {
value: action.value,
});
default:
return state;
}
}
CSS-Tricks
https://css-tricks.com/learning-react-redux/
Smart: Describe how things work
- Provide no DOM markup or styles
- Provide application data, do data fetching
- Call Flux actions
- Named *Container by convention
Dumb: Describe how things look
- Have no app dependencies
- Receive only props, providing data and callbacks
- Rarely have own state, when they do, it’s just UI state
- Named anything that’s a UI noun
From https://jaketrent.com/post/smart-dumb-components-react/
From https://jaketrent.com/post/smart-dumb-components-react/
From https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0
Dan Abromov
http://redux.js.org/docs/faq/General.html
https://bvaughn.github.io/react-virtualized/#/components/Collection
https://bvaughn.github.io/react-virtualized/#/components/Collection
http://airbnb.io/react-dates