feat: add support for React@18 in backward compatible way (#9435)

Any React version matching this semver is supported: >= 16.8 < 19

Refs #8126
Refs #8414
This commit is contained in:
Vladimír Gorej
2023-12-20 16:50:22 +01:00
committed by GitHub
parent 08fe66b8fd
commit 98b53090cb
11 changed files with 2153 additions and 24278 deletions

View File

@@ -0,0 +1,25 @@
/**
* @prettier
*/
import { getComponent } from "core/plugins/view/root-injects"
import { render } from "./root-injects"
const ViewLegacyPlugin = ({ React, getSystem, getStore, getComponents }) => {
const rootInjects = {}
const reactMajorVersion = parseInt(React?.version, 10)
if (reactMajorVersion >= 16 && reactMajorVersion < 18) {
rootInjects.render = render(
getSystem,
getStore,
getComponent,
getComponents
)
}
return {
rootInjects,
}
}
export default ViewLegacyPlugin

View File

@@ -0,0 +1,12 @@
/**
* @prettier
*/
import React from "react"
import ReactDOM from "react-dom"
export const render =
(getSystem, getStore, getComponent, getComponents) => (domNode) => {
const App = getComponent(getSystem, getStore, getComponents)("App", "root")
ReactDOM.render(<App />, domNode)
}