2

Recently I had learnt react-redux, I use it to manage state in my website. But I find some interest in react suspense, but seem like suspense is a feature that killing redux. (Maybe) and might cause problem if using together.

For example, if I want to perform async to change state and update the store. Where should I apply the suspense “feature” and redux store update.

I know my question is a bit confusing but I hope you can understand what I said.

Anyone know how to manage state in react SAP if I want to use react suspense? Is only usecontext is usable?

Wesley Loh
  • 153
  • 2
  • 11
  • 1
    I don't think you're understanding what suspense does. It is not equivalent to redux. Plus, it's still experimental. Read through the React docs on it [here](https://reactjs.org/docs/concurrent-mode-suspense.html). – Brian Thompson Mar 24 '20 at 21:28
  • 2
    @BrianThompson It should be clarified that `Suspense` itself isn't experimental, it's part of standard React now (primarily for [code splitting](https://reactjs.org/docs/code-splitting.html)), and that "concurrent mode" is what is still experimental. – Drew Reese Mar 24 '20 at 21:45
  • 1
    Suspense certainly isn't "killing" Redux. For one thing, it's not out in a final form yet. We're not exactly sure how Suspense and Redux will integrate down the road, but the React team is still planning some significant changes to how it behaves and it's hard for us to figure that out until the APIs are stable. – markerikson Mar 24 '20 at 21:47

1 Answers1

0

One way you can use suspense and redux together is by using a Suspense library that integrates with redux like Rest Hooks

Suspense and redux are distinct concepts that can be used independently, or together.

Suspense simplifies asynchronous handling, allowing co-location of data dependencies, which makes components independent from their render location, and thus reusable.

Redux enables one centralized store tree, which can be useful when combining information across desperate concepts in a centralized stream.

Nathaniel Tucker
  • 577
  • 1
  • 5
  • 17