Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync data fetching and normalization in real world use case #1731

Closed
otakustay opened this issue Jun 10, 2021 · 1 comment
Closed

Sync data fetching and normalization in real world use case #1731

otakustay opened this issue Jun 10, 2021 · 1 comment

Comments

@otakustay
Copy link
Contributor

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 async useEffect to dispatch actions putting data into redux store, while useEffect 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 architectures

What 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

@markerikson
Copy link
Contributor

markerikson commented Jun 10, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants