Currently within my app I have multiple Routes using React Router that are wrapped within the Redux provider.
Provider
<Provider store={store}>
<Router>
<Route exact path ="/" component = {LoginPage}></Route>
<Route exact path="/login" component ={LoginPage}/>
<Route path ="/change" component={MasterPage}/>
<Route path="/change/form" component={ChangeForm}/>
<Route path="/change/table" component={ExpandTable} />
</Router>
</Provider>
As it stands I'm confused how I'm supposed to being passing/accessing the state of the store within the components.
The only state that I really need to be storing is the current status of the user login and want to use this to change what is rendered on the other routes.
Reducer
I have a reducer which looks like:
export default (state = {}, action) => {
switch (action.type) {
case 'SIMPLE_ACTION':
return {
loggedIn: action.loggedIn,
User: action.User,
Group: action.Group
}
default:
return state
}
}
Action
And an action which looks like
export const simpleAction = () => dispatch => {
dispatch({
type: 'SIMPLE_ACTION',
payload: data
})
}
Now I'm currently working under the assumption that connecting them to the store using
export default connect(mapStateToProps, mapDispatchToProps)(LoginForm);
would allow me to access the store within that component, but it seems that isn't the case.
I'm a little confused as to how to access the store state within the component and also how to properly write the action/reducer to change this state.