I have a <Category />
component. Redux Router pases all the category/ urls inside it. The problem is with store update. I am setting CategoryContent
store with initial values in componentDidMount()
, but when i am navigating from category to category, it uses the same component, so i cant chage my CategoryContent
store in this hook. I also cant call it in my render function. So what is the right way to change my store, when i am navigating my site? Maybe there is some hoot on url change or something?
<DefaultPage path="/category" component={Category} />
so every category is set will use my Category
component. When i go to /category I am dispatching an action to load a content by calling loadPageContent()
:
const mapDispatchToProps = dispatch => {
return {
loadPageContent: page => {
dispatch(loadPageContent(page))
}
}
}
const mapStateToProps = state => {
return {
categories: state.page.categories,
pageContent: state.page.pageContent,
}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(Category);