React Native render not being triggered after Redux action is dispatched -
i'm having issue, action being dispatched, reducer being executed render function not being triggered.
container:
import react, { component } 'react'; import { bindactioncreators } 'redux'; import { connect } 'react-redux'; import { rendervotersearch } '../actions'; import search '../components/search'; class searchcontainer extends component { render() { return ( <search {...this.props}/> ); } } const mapstatetoprops = (state) => { return { searchtype: state.searchtype, instruction: state.instruction, title: state.title } } const mapdispatchtoprops = (dispatch) => { return bindactioncreators({ rendervotersearch }, dispatch); } export default connect(mapstatetoprops, mapdispatchtoprops)(searchcontainer);
the action dispatched search component
export const rendervotersearch = (tab) => ({ type: render_voter_search, searchtype: tab.type, instruction: tab.instruction, title: tab.title });
reducer:
const search = (state = initialstate, action) => { switch (action.type) { case render_voter_search: return { ...state, searchtype: action.searchtype, instruction: action.instruction, title: action.title } default: return state } }
here's complete code https://github.com/mivotico/mivotico-react-native/tree/redux-first-steps/app
i've been reading 1 of reasons may state being mutated checked , didn't see mutation.
thanks in advance!
found issue! didn't know reducers inside state, if reducer called "search" in mapstatetoprops
function access state should state.search
instead of state
.
Comments
Post a Comment