Skip to content

Commit cc2d908

Browse files
eps1lonsebmarkbage
andcommitted
Fix JSX
Co-authored-by: Sebastian Markbåge <[email protected]>
1 parent 1a544ea commit cc2d908

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

src/pages/[[...markdownPath]].js

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,27 @@ function useActiveSection() {
7171
}
7272

7373
// Deserialize a client React tree from JSON.
74-
function reviveNodeOnClient(key, val) {
74+
function reviveNodeOnClient(parentPropertyName, val) {
7575
if (Array.isArray(val) && val[0] == '$r') {
7676
// Assume it's a React element.
77-
let type = val[1];
77+
let Type = val[1];
7878
let key = val[2];
79+
if (key == null) {
80+
key = parentPropertyName; // Index within a parent.
81+
}
7982
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};
8386
}
84-
if (MDXComponents[type]) {
85-
type = MDXComponents[type];
87+
if (Type in MDXComponents) {
88+
Type = MDXComponents[Type];
8689
}
87-
if (!type) {
88-
console.error('Unknown type: ' + type);
89-
type = Fragment;
90+
if (!Type) {
91+
console.error('Unknown type: ' + Type);
92+
Type = Fragment;
9093
}
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} />;
10095
} else {
10196
return val;
10297
}

0 commit comments

Comments
 (0)