Codesandbox: https://codesandbox.io/s/condescending-wiles-funk0?file=/src/App.js
Problem: When I update the state of my store the components are not re-rendered. In the above example you can see from the console that the data is correctly fetched, but the component is not re-rendered and keep rendering just Loading...
.
Expected behavior: When I update the state, the components are re-rendered.
I found a workaround by using useState in the component and subscribing to store changes like:
store.subscribe(() => setComponentState(store.getData())
This basically forces a re-render each time the data is updated.
I can mutate state: In the official docs they say that you can mutate the state since it has some magic that allows to do so (https://redux-toolkit.js.org/usage/usage-guide#simplifying-reducers-with-createreducer), hence that's not the issue.
Anyone has any idea about what's the appropriate way to make it work?