Implementing React.Suspense

First, we have to specify a loading indicator, which will be shown when our lazily-loaded component is loading. In our example, we are going to wrap the UserBar component with React Suspense.

Edit src/App.js, and replace the <UserBar /> component with the following code:

                    <React.Suspense fallback={"Loading..."}>
<UserBar />
</React.Suspense>

Now, our app is ready for implementing lazy loading.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.63.136