Closed otakustay closed 3 years ago
There's a couple problems with this issue.
First, this repo is for React-Redux, which is the bindings layer between a Redux store and your React components. Any requests for features related to core Redux logic aren't relevant in this repo.
Second, we just released our brand new "RTK Query" API as part of Redux Toolkit 1.6, which is a purpose-built data fetching solution built for Redux usage. Please see the RTK Query docs for details on how to use it:
https://redux-toolkit.js.org/rtk-query/overview
Third, "normalization" is a completely different question than "data fetching" and "Suspense".
We'll look at adding Suspense support into RTK Query down the road.
New Features
Currently we don't have a solution for sync data fetching and normalization working together.
The key problem is, when we do a sync data fetching (by directly
const data = readData()
) in render function, we have to introduce an asyncuseEffect
to dispatch actions putting data into redux store, whileuseEffect
is async, sync rendered children cannot reach fetched data.I've created a sandbox to demonstrate this issue: https://codesandbox.io/s/dazzling-worker-73nem?file=/src/App.tsx
Since react is going forward to 18 and suspense data fetching is about to land, this pattern can be more and more popular in the future.
What is the new or updated feature that you are suggesting?
Should be a new feature
Why should this feature be included?
Normalization is a good idea for robust applications but it is now working well with sync data fetching like
Suspense
, this can introduce risks when we want to move to newer architecturesWhat docs changes are needed to explain this?
I don't have any idea about how it can be solved, but this is a problem for current
react-redux