Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Redux Reducer Help

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #247330
    tomhanson1985
    Participant

    Hi,

    I was just wondering if someone could help me solve a problem I am having with redux. I have posted a pen as best as I can with the code in it here:

    http://codepen.io/tomhanson1985/pen/oYveQE?editors=1010

    Apologies if it is messy but I am pretty new to Redux!

    Just to clarify what I am trying to do:

    When a link is clicked or a component loads it dispatches an action passing the page slug to it. I use that page slug to query a rest api(wordpress one) and then when the data comes back I want to store it in the store using the page slug as the name of the property.

    i.e

    about-us : /*about us page data */

    My question is this: The reducer I have put in that pen works exactly how I thought it would but it mutates the state which everything I read tells me is a big no no! I’ve tried refactoring it with no joy as of yet!

    Hopefully that all makes sense!

    #247331
    tomhanson1985
    Participant

    typically I found a solution around 1 minute after pulling my hair out all day and then posting this message! Not sure if its the best way but I updated my pen with the new code which does seem to work.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.