BT

Ready for InfoQ 3.0? Try the new design and let us know what you think!

React Suspense Provides Redux Alternative

| by Dylan Schiemann Follow 12 Followers on Dec 03, 2018. Estimated reading time: 1 minute |

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 Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
BT