Skip to content
프로젝트

nandorojo/react-navigation-heavy-screen

GitHub에서 보기

소개

⚡️React Navigation 전환 중 지연이 발생하지 않도록 무거운 화면을 최적화하세요.

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

⚡️ Speed up heavy React Native screens

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.

Usage

🥳 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 ^

Installation

yarn add react-navigation-heavy-screen

Install peer dependencies:

expo install react-native-reanimated

What does it do?

Delay rendering a component until interactions are complete, using InteractionManager. Then it fades in your screen.


<OptimizedHeavyScreen />

Props

  • placeholder (optional) Non-heavy React component that renders in the meantime.
  • Extends Animated.View props docs. So you can pass any props you need to customize the animation. eg: { entering: { FadeIn } }
import React from 'react'
import { OptimizedHeavyScreen } from 'react-navigation-heavy-screen'

const Screen () => (
  <OptimizedHeavyScreen>
    <YourHeavyComponent />
  </OptimizedHeavyScreen>
)

export default Screen

optimizeHeavyScreen(Screen, Placeholder, options)

import { optimizeHeavyScreen } from 'react-navigation-heavy-screen'

export default optimizeHeavyScreen(Screen, OptionalPlaceHolderScreen, {
  // default values
  disableHoistStatics: false,
})

Arguments

  • 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:
    • disableHoistStatics: (optional) If true, the Screen's statics (like navigationOptions, etc.) will not be passed on. Default: false.
    • Extends Animated.View props docs. So you can pass any props you need to customize the animation. eg: { entering: { FadeIn } }

License

MIT

관련 프로젝트 살펴보기

불러오는 중…