BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News React Suspense Provides Redux Alternative

React Suspense Provides Redux Alternative

Leia em Português

This item in japanese

React 16.6 introduces Suspense, the ability to suspend rendering and display a loading indicator while waiting for something such as data from an API call.

In common simple cases, React Suspense removes the need for Redux, as explained by React expert Ryan Florence:

If your primary use-case for Redux is using it as a client-side cache of server-side data, then Suspense could replace your redux usage. I’d consider it because you’d have simpler code and the ability to tame all those spinners.

For more complex state management such as synchronizing state to both an API and localStorage, an approach like Redux provides value beyond Suspense.

Bartosz Szczeciński, a software developer at GFT Poland, predicts that Suspense will have a significant impact on React usage:

We will probably see a lot of libraries pioneering the solution and will have to adjust our best practices (suddenly calling AJAX requests inside render will become OK) but I believe this will allow us all to create even better applications and experience for users!

The React 16.6 release includes only one use case for suspense, the lazy loading of components with React.lazy() and <React.Suspense>. React's approach to optimization with code splitting and Suspense is documented within the React Code Splitting guide.

Beyond code splitting, the React team plans to add additional capabilities to Suspense including the handling of data fetching and integration with GraphQL libraries.

Server-side rendering support for Suspense is planned for 2019.

React is an open source software available under the MIT license. Contributions and feedback are encouraged via the React GitHub project and should follow the React contribution guidelines and Facebook open source code of conduct.

Rate this Article

Adoption
Style

BT