This repository was archived by the owner on Nov 27, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed
Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,7 @@ renderScene = ({ route }) => {
223223
224224Where ` <HomeComponent /> ` is a ` PureComponent ` .
225225
226+ If you are using the ` SceneMap ` helper, the scenes are already optimized with ` PureComponent ` and won't re-render if parent's state changes.
226227
227228### Avoid one frame delay
228229
Original file line number Diff line number Diff line change 33import React , { PureComponent } from 'react' ;
44
55export default function SceneMap ( scenes : { [ key : string ] : Function } ) {
6- return ( { route } : * ) => {
7- class SceneComponent extends PureComponent {
8- static displayName = `SceneMap(${ route . key } )` ;
9-
10- render ( ) {
11- return React . createElement ( scenes [ route . key ] , this . props ) ;
12- }
6+ class SceneComponent extends PureComponent < void , * , void > {
7+ render ( ) {
8+ /* eslint-disable react/prop-types */
9+ return React . createElement ( scenes [ this . props . route . key ] , this . props ) ;
1310 }
14- return < SceneComponent key = { route . key } route = { route } /> ;
15- } ;
11+ }
12+
13+ return ( { route } : * ) => < SceneComponent key = { route . key } route = { route } /> ;
1614}
You can’t perform that action at this time.
0 commit comments