package
Optimize heavy screens to prevent lags with React Navigation.
npm install react-navigation-heavy-screenGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Optimize heavy screens in React Native to prevent lags with React Navigation's stack.
This isn't actually specific to React Navigation, but I find myself using it there often.
Especially useful for screens that set up listeners, make network requests, etc.
🥳 New component-based API! Use this if you only want to optimize certain content on your screen.
import React from 'react'
import { OptimizedHeavyScreen } from 'react-navigation-heavy-screen'
const Screen = () => (
<>
<NonExpensiveComponentHere />
<OptimizedHeavyScreen>
<MyHeavyComponentHere />
</OptimizedHeavyScreen>
</>
)You can also use the normal export usage. Use this if you want to optimize your whole screen.
import { optimizeHeavyScreen } from 'react-navigation-heavy-screen'
const Screen = () => ...
export default optimizeHeavyScreen(Screen, OptionalPlaceHolderScreen)Or you can require your heavy screen inline:
import { optimizeHeavyScreen } from 'react-navigation-heavy-screen'
export default optimizeHeavyScreen(
require('path/to/HeavyScreen'),
OptionalPlaceHolderScreen
)Thanks to @Sebastien Lorber for this recommendation ^
yarn add react-navigation-heavy-screenInstall peer dependencies:
expo install react-native-reanimatedDelay rendering a component until interactions are complete, using InteractionManager. Then it fades in your screen.
<OptimizedHeavyScreen />placeholder (optional) Non-heavy React component that renders in the meantime.transition: (optional) custom transition prop for Reanimated's Transitioning.View component. See react-native-reanimated docs and Transition examples.import React from 'react'
import { OptimizedHeavyScreen } from 'react-navigation-heavy-screen'
const Screen () => (
<OptimizedHeavyScreen>
<YourHeavyComponent />
</OptimizedHeavyScreen>
)
export default ScreenoptimizeHeavyScreen(Screen, Placeholder, options)import { optimizeHeavyScreen } from 'react-navigation-heavy-screen'
export default optimizeHeavyScreen(Screen, OptionalPlaceHolderScreen, {
// default values
disableHoistStatics: false,
transition: (
<Transition.Together>
<Transition.Change interpolation="easeInOut" />
<Transition.In type="fade" />
</Transition.Together>
),
})Screen required Any React component whose render should be delayed until interactions are complete.Placeholder (optional) Non-heavy React component that renders in the meantime.options (optional) Dictionary with the following options:
MIT
Estimated unpacked size across 7 packages.
245.2 kB
Includes dependencies.
2 direct dependencies.
^3.3.2
3.3.2
^1.3.3
1.4.0