Skip to content
Advertisement

An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft

I understand this has been asked before but so far no answers except someone making a syntax mistake. I have verified this against every tutorial I’ve seen online and I can’t find the issue. It seems to be coming from the fullfilled extraReducer

JavaScript

In the component, nothing weird, and yes everything is imported

JavaScript

You can see in my image below that my fetch is successful and I am getting data. So how do I get rid of this error? Thanks in advance.

enter image description here

Advertisement

Answer

This is the issue:

JavaScript

That is indeed both a “mutation of the existing stateand a “return of a new value”, and that’s exactly what the error is warning you about.

You can change that to:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement