More Redux Practice?

More Redux Practice?
0.0 0

#1

Any advice on a good place to practice with Redux? These challenges are pretty frustrating.


#2

The Redux site:

https://redux.js.org/

And the Egghead course from the creator is free:


#3

I know you’ve edited your question, but I’d still like to clear up how to create new copies of the state, since I believe I didn’t make it clear enough in my other answer.

These are the ways to copy state in your reducer

// works for objects
const newState = Object.assign({}, oldState, updatedState)
const newState = {...oldState, ...updateState}

// works for arrays
const copyOfState = oldState.slice()
const copyOfState = [...oldState]

Hopefully that clears it up any confusion I caused.

Also, on top of @DanCouper’s suggestion, I used Stephen Grider’s react redux course on udemy. They’re only $10 each


#4

The confusion came from the challenges, or me not fully understanding them. A more careful reading showed me my mistake: I thought that everything in Redux should be immutable and needed to be copied, so I was trying to make copies of text: action.text.

Now I understand that only the state should be immutable. I’m finding the React and Redux sections to be confusing me more than teaching me. I think code is better taught with examples, not jargon-laden paragraphs.


#5

Yeah, I’d definitely take a detour through some of the suggestions if your feeling that way. Redux is very, very simple (even if that simplicity translates into lots of boilerplate code), it just takes a little while to click.

(All your state goes in one single object that you can access from anywhere in the app. That object is immutable. Whenever you want to update the state, you take the state object you have + the values you want changing, and create a brand new state object with the updated values (a reduce operation, same as the JS array method reduce))