@@ -71,33 +71,33 @@ function DashWrapper({
71
71
const memoizedKeys : MutableRefObject < MemoizedKeysType > = useRef ( { } ) ;
72
72
const memoizedProps : MutableRefObject < MemoizedPropsType > = useRef ( { } ) ;
73
73
const newRender = useRef ( false ) ;
74
+ let renderComponent : any = null ;
75
+ let renderComponentProps : any = null ;
76
+ let renderH : any = null ;
74
77
75
78
// Get the config for the component as props
76
79
const config : DashConfig = useSelector ( selectConfig ) ;
77
80
78
- // Select both the component and it's props.
79
- // eslint-disable-next-line prefer-const
80
- let [ component , componentProps , h , changedProps , renderType ] = useSelector (
81
- selectDashProps ( componentPath ) ,
82
- selectDashPropsEqualityFn
83
- ) ;
81
+ // Select component and it's props, along with render hash, changed props and the reason for render
82
+ const [ component , componentProps , h , changedProps , renderType ] =
83
+ useSelector ( selectDashProps ( componentPath ) , selectDashPropsEqualityFn ) ;
84
+
85
+ renderComponent = component ;
86
+ renderComponentProps = componentProps ;
87
+ renderH = h ;
84
88
85
- /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-vars */
86
- // @ts -ignore
87
- const newlyRendered : any = useMemo ( ( ) => {
89
+ useMemo ( ( ) => {
88
90
if ( _newRender ) {
89
91
memoizedProps . current = { } ;
90
92
newRender . current = true ;
91
- h = 0 ;
93
+ renderH = 0 ;
92
94
if ( h in memoizedKeys . current ) {
93
95
delete memoizedKeys . current [ h ] ;
94
96
}
95
97
} else {
96
98
newRender . current = false ;
97
99
}
98
- return newRender . current ;
99
100
} , [ _newRender ] ) ;
100
- /* eslint-enable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-vars */
101
101
102
102
memoizedProps . current = componentProps ;
103
103
@@ -163,8 +163,8 @@ function DashWrapper({
163
163
164
164
const createContainer = useCallback (
165
165
( container , containerPath , _childNewRender , key = undefined ) => {
166
- if ( isSimpleComponent ( component ) ) {
167
- return component ;
166
+ if ( isSimpleComponent ( container ) ) {
167
+ return container ;
168
168
}
169
169
return (
170
170
< DashWrapper
@@ -220,7 +220,7 @@ function DashWrapper({
220
220
...extras
221
221
} as { [ key : string ] : any } ;
222
222
223
- if ( checkRenderTypeProp ( component ) ) {
223
+ if ( checkRenderTypeProp ( renderComponent ) ) {
224
224
extraProps [ 'dashRenderType' ] = newRender . current
225
225
? 'parent'
226
226
: changedProps
@@ -246,7 +246,7 @@ function DashWrapper({
246
246
. replace ( '[]' , '' )
247
247
. replace ( '{}' , '' ) in changedProps ||
248
248
newRender . current ||
249
- ! h
249
+ ! renderH
250
250
) {
251
251
childNewRender = { } ;
252
252
}
@@ -444,22 +444,27 @@ function DashWrapper({
444
444
445
445
const hydrateFunc = ( ) => {
446
446
if ( newRender . current ) {
447
- component = _passedComponent ;
448
- componentProps = _passedComponent ?. props ;
447
+ renderComponent = _passedComponent ;
448
+ renderComponentProps = _passedComponent ?. props ;
449
449
}
450
- if ( ! component ) {
450
+ if ( ! renderComponent ) {
451
451
return null ;
452
452
}
453
453
454
- const element = Registry . resolve ( component ) ;
455
- const hydratedProps = setHydratedProps ( component , componentProps ) ;
454
+ const element = Registry . resolve ( renderComponent ) ;
455
+ const hydratedProps = setHydratedProps (
456
+ renderComponent ,
457
+ renderComponentProps
458
+ ) ;
456
459
457
460
let hydratedChildren : any ;
458
- if ( componentProps . children !== undefined ) {
461
+ if ( renderComponentProps . children !== undefined ) {
459
462
hydratedChildren = wrapChildrenProp (
460
- componentProps . children ,
463
+ renderComponentProps . children ,
461
464
[ 'children' ] ,
462
- ! h || newRender . current || 'children' in changedProps ? { } : 0
465
+ ! renderH || newRender . current || 'children' in changedProps
466
+ ? { }
467
+ : 0
463
468
) ;
464
469
}
465
470
newRender . current = false ;
@@ -468,7 +473,7 @@ function DashWrapper({
468
473
< CheckedComponent
469
474
element = { element }
470
475
props = { hydratedProps }
471
- component = { component }
476
+ component = { renderComponent }
472
477
>
473
478
{ createElement (
474
479
element ,
@@ -483,14 +488,14 @@ function DashWrapper({
483
488
} ;
484
489
485
490
let hydrated = null ;
486
- if ( h in memoizedKeys . current && ! newRender . current ) {
487
- hydrated = React . isValidElement ( memoizedKeys . current [ h ] )
488
- ? memoizedKeys . current [ h ]
491
+ if ( renderH in memoizedKeys . current && ! newRender . current ) {
492
+ hydrated = React . isValidElement ( memoizedKeys . current [ renderH ] )
493
+ ? memoizedKeys . current [ renderH ]
489
494
: null ;
490
495
}
491
496
if ( ! hydrated ) {
492
497
hydrated = hydrateFunc ( ) ;
493
- memoizedKeys . current = { [ h ] : hydrated } ;
498
+ memoizedKeys . current = { [ renderH ] : hydrated } ;
494
499
}
495
500
496
501
return component ? (
0 commit comments