Skip to content

Commit 3636404

Browse files
committed
add detection for Reacts varying render functions
1 parent f77ae20 commit 3636404

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

react_ujs/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,14 @@ var ReactRailsUJS = {
111111
}
112112
}
113113

114-
if (hydrate && typeof ReactDOM.hydrate === "function") {
115-
component = ReactDOM.hydrate(component, node);
114+
if (hydrate && typeof ReactDOM.hydrateRoot === "function") {
115+
component = ReactDOM.hydrateRoot(component, node);
116116
} else {
117-
component = ReactDOM.render(component, node);
117+
const root = ReactDOM.createRoot(node)
118+
component = root.render(component);
118119
}
119120
}
120-
}
121+
}
121122
},
122123

123124
// Within `searchSelector`, find nodes which have React components

0 commit comments

Comments
 (0)