You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is a suggestion that would make the doc clearer to me. Don't know if that is the majority of the user base. I have only read 80% of the doc so could have missed something, so apology if I did.
I got from the doc that you 'could mutate state or not but not both' and the doc was clear to me on how to mutate state but no on how to not mutate when you didn't want to.
And spent a while trying to figure how why the store was not updating.
hope I got that work but my code is working now
I think a useful addition would be to
make it clearer that in the rare case you don't want to mutate state you just need the return keyword with the new state.
I also didn't see any place that said what would the result will be if you did state = newState, which in my case was the store didn't update.
A third thing I didn't get from the doc was if you could make the mutate vs not mutate choice on a per reducer basis rather than on some larger slice or project level. Making point Create LICENSE #1 clearer would solve this.
The text was updated successfully, but these errors were encountered:
Yeah, please feel free to submit PRs to improve any docs phrasing or descriptions you feel aren't clear enough.
In this specific case, state = newState simply points the local function variablestate to something else. Immer works by tracking mutations, ie, state.someField = newValue, and also allows returning an entire new result. Pointing a local argument to something else will have no effect.
Here is a suggestion that would make the doc clearer to me. Don't know if that is the majority of the user base. I have only read 80% of the doc so could have missed something, so apology if I did.
I got from the doc that you 'could mutate state or not but not both' and the doc was clear to me on how to mutate state but no on how to not mutate when you didn't want to.
This thread made it clear to me: #242
If I'm understanding things correctly:
mutate state
don't mutate
I accidentally did (i.e., not mutation0
And spent a while trying to figure how why the store was not updating.
I think a useful addition would be to
return
keyword with the new state.state = newState
, which in my case was the store didn't update.The text was updated successfully, but these errors were encountered: