namgold
namgold

Reputation: 1070

react-loadable callback when load done?

Is there any callback for react-loadable when it loaded the component? I can not find any info in the document of react-loadable.

Upvotes: 2

Views: 952

Answers (1)

hangindev.com
hangindev.com

Reputation: 4883

You may make use of its loader property or render method:

Loadable({
  loader: () =>
    import("./components/Bar").then(Bar => {
      console.log("loaded"); // Put your callback here
      return Bar;
    }),
});

or,

Loadable({
  loader: () => import("./components/Bar"),
  render(loaded, props) {
    console.log("loaded"); // Put your callback here
    let Component = loaded.default;
    return <Component {...props} />;
  },
});

Upvotes: 2

Related Questions