0

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);
Raviteja
  • 3,257
  • 21
  • 32
  • 59
Zoltan
  • 63
  • 5
  • Why do you mean by `i am navigating from category to category` – Shubham Khatri Apr 06 '18 at 07:00
  • When you are navigating to a category, I assume that you know this category's id, or any other unique attribute, that differentiates this category from another category, right? So why do you have a problem accessing this specific category in the store? – Yossi Apr 06 '18 at 07:08
  • this might help you https://stackoverflow.com/questions/48139281/react-doesnt-reload-component-data-on-route-param-change/48139367#48139367 – Shubham Khatri Apr 06 '18 at 07:11
  • Please share some code here. This would help everyone to understand you question / problem better. – Shobhit Chittora Apr 06 '18 at 07:46
  • @ShobhitChittora i added some code if you need something specific just ask for ) – Zoltan Apr 06 '18 at 07:57
  • @ ShubhamKhatri it mean that i am navigatin from category/1 to category/2 for example. – Zoltan Apr 06 '18 at 08:20

0 Answers0