stackerLoki
stackerLoki

Reputation: 93

React-Loadable how to return component?

const PageDocuments = Loadable({
    loader: () => import('./pages/documentflow/PageDocuments'),
    loading:  ({error}) => {
        if (error) {
            console.log(error);
        }
    },
});

<LayoutDefault path={PageDocuments.Path} component={PageDocuments}/>

I have error loading(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null. How i can use return for get all component?

Upvotes: 1

Views: 210

Answers (1)

Yash Joshi
Yash Joshi

Reputation: 2784

The error says it all as loading property requires you to return a Component and you are not returning anything from loading.

If you don't want to show a loading component you can return null.

You can take a look at this example for more detail: https://github.com/jamiebuilds/react-loadable#loadingcomponent

Here is the doc for the same: https://github.com/jamiebuilds/react-loadable#optsloading

Hope this helps!

Upvotes: 1

Related Questions