File tree Expand file tree Collapse file tree 1 file changed +14
-19
lines changed Expand file tree Collapse file tree 1 file changed +14
-19
lines changed Original file line number Diff line number Diff line change @@ -71,32 +71,27 @@ function useActiveSection() {
71
71
}
72
72
73
73
// Deserialize a client React tree from JSON.
74
- function reviveNodeOnClient ( key , val ) {
74
+ function reviveNodeOnClient ( parentPropertyName , val ) {
75
75
if ( Array . isArray ( val ) && val [ 0 ] == '$r' ) {
76
76
// Assume it's a React element.
77
- let type = val [ 1 ] ;
77
+ let Type = val [ 1 ] ;
78
78
let key = val [ 2 ] ;
79
+ if ( key == null ) {
80
+ key = parentPropertyName ; // Index within a parent.
81
+ }
79
82
let props = val [ 3 ] ;
80
- if ( type === 'wrapper' ) {
81
- type = Fragment ;
82
- props = { children : [ props . children ] } ;
83
+ if ( Type === 'wrapper' ) {
84
+ Type = Fragment ;
85
+ props = { children : props . children } ;
83
86
}
84
- if ( MDXComponents [ type ] ) {
85
- type = MDXComponents [ type ] ;
87
+ if ( Type in MDXComponents ) {
88
+ Type = MDXComponents [ Type ] ;
86
89
}
87
- if ( ! type ) {
88
- console . error ( 'Unknown type: ' + type ) ;
89
- type = Fragment ;
90
+ if ( ! Type ) {
91
+ console . error ( 'Unknown type: ' + Type ) ;
92
+ Type = Fragment ;
90
93
}
91
- return {
92
- $$typeof : Symbol . for ( 'react.transitional.element' ) ,
93
- type : type ,
94
- key : key ,
95
- ref : null ,
96
- _store : { validated : 0 } ,
97
- props : props ,
98
- _owner : null ,
99
- } ;
94
+ return < Type key = { key } { ...props } /> ;
100
95
} else {
101
96
return val ;
102
97
}
You can’t perform that action at this time.
0 commit comments