How to load react on demand in the loading state that js has not finished loading? getComponent

react-router3
require.ensure ([], (require) = > {}) load on demand
I want to give js a loading state. How do I do this? Similar to a load bar at the top of the page

Nov.25,2021

this.setState({
  loading: true
});
require.ensure([], (require) => {
   require('../xxx.js');
   this.setState({
     loading: false
   });
})
Menu