Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is React.lazy gonna improve React Native performance?

I'm wondering how React.lazy gonna improve performance in React-Native app.

const Warning = React.lazy(() => import('./Warning'));
...

render() {
  return (
    ...
    {
      {this.state.count > 10 ? (
          <React.Suspense fallback={null}>
            <Warning />
          </React.Suspense>
        ) : null}
    }
  )
}

I get to know the above dynamic loading webpack bundles in ReactJS side and I'm wondering if it's gonna help in React Native side?

Essentially we bundled all the JS code together and ship together to user device, all the JS code are already there, sitting in the user device. Wondering how React.lazy gonna help improving performance, in which sense?

like image 240
Isaac Avatar asked Jan 27 '19 11:01

Isaac


1 Answers

No definitely not. But it may improve your app's startup time. If you got many screens then your app startup time will go slow without lazy import. Check your app startup time without lazy import and after implementing the lazy import.

like image 144
Vetri vendhan Avatar answered Oct 13 '22 10:10

Vetri vendhan