Consider the following short code snippet.
Immer seems to have a problem with readonly arrays, which doesn't make sense to me, because your state should always be immutable, which is the whole point of using immer in the first place.
Before Immer version 7, this pattern worked fine, but in Immer 8+, it throws an error. How do I work around this problem or structure my code in the correct way?
You'll have to cast your state, like this -
Here's a playground link and here's where you can read more about it.