i just started to write code in redux and am facing some issues while getting value from redux store
browse-upload.js
const initialState = {
modal: false
};
const browseUploadReducer = (state = initialState, action) => {
switch (action.type) {
case GET_MODAL_INFORMATION: {
return {
...state,
modal: true
};
}
case GET_CLOSE_MODAL_INFORMATION: {
return {
...state,
modal: false
};
}
default:
return state;
break;
}
};
export const getModalOpen = () => (dispatch) => {
dispatch({
type: GET_MODAL_INFORMATION
});
};
export const getModalClose = () => (dispatch) => {
dispatch({
type: GET_CLOSE_MODAL_INFORMATION
});
};
export default browseUploadReducer;
and in my component , i just tried to retrieve the value from store
import { getModalOpen,getModalClose} from 'reducers/star/browse-upload';
const mapStateToProps = state => ({
modal: state.modal,
});
what might went wrong ?Still control not coming back to component? How can i verify that?
browseUploadReducerto yourcombineReducerfunction.const mapStateToProps = state => ({ modal: state.modal });state.browseUploaditsundefined. therefore, you are gettingundefine.modalwhere as undefined is not an object. so, first you should get an object or a value instate.browseUpload