Reputation: 576
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?
Upvotes: 1
Views: 741
Reputation: 1602
In your mapStateToProps
, write this:
const mapStateToProps = state => ({ modal: state.modal });
I think issue is; there is no such thing called browseUpload
defined in your state that is why you are getting the error.
Upvotes: 3