This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const store = createStore(combineReducers({ | |
products: productsReducer, | |
... | |
})); | |
ReactDOM.render( | |
<Provider store={store}> | |
<Main /> | |
</Provider>, | |
document.getElementById('root') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function saveUser(user) { | |
// um thunk tem acesso à metodos da Store | |
return function(dispatch, getState) { | |
// ... | |
} | |
} | |
store.dispatch(saveUser(user)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function firstReducer(state, action) { | |
if (action.type === 'LOGIN_PENDING') console.log('firstReducer log'); | |
return state; | |
} | |
function secondReducer(state, action) { | |
if (action.type === 'LOGIN_PENDING') console.log('secondReducer log'); | |
return state; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.jsx | |
const store = createStore(combineReducers({ | |
products: productsReducer, | |
... | |
})); | |
// list-products.component.jsx | |
const dispatch = useDispatch(); // retorna store.dispatch | |
dispatch({ type: 'ADD_PRODUCT', payload: { id: 123, name: 'product 1', ... } }); | |
... |