diff --git a/src/lib/react/React.hx b/src/lib/react/React.hx index fa7ade1..6d42637 100644 --- a/src/lib/react/React.hx +++ b/src/lib/react/React.hx @@ -5,10 +5,17 @@ import react.ReactComponent.ReactElement; /** https://facebook.github.io/react/docs/react-api.html **/ + +#if (jsImport) +@:js.import(@default "react") +#else + #if (!react_global) @:jsRequire("react") #end + @:native('React') +#end extern class React { // Warning: react.React.PropTypes is deprecated, reference as react.ReactPropTypes @@ -59,6 +66,13 @@ extern class React public static function forwardRef(render:TProps->ReactRef->ReactElement):CreateElementType; #end + /** + https://react.dev/reference/react/StrictMode + + Note: this API has been introduced in React 16.3 + **/ + public static var StrictMode:CreateElementType; + /** https://facebook.github.io/react/docs/react-api.html#react.children **/ diff --git a/src/lib/react/ReactComponent.hx b/src/lib/react/ReactComponent.hx index a49716b..bc4a2f9 100644 --- a/src/lib/react/ReactComponent.hx +++ b/src/lib/react/ReactComponent.hx @@ -24,10 +24,16 @@ typedef ReactComponentOfState = ReactComponentOf; // Keep the old ReactComponentOfPropsAndState typedef available a few versions typedef ReactComponentOfPropsAndState = ReactComponentOf; +#if (jsImport) +@:js.import("react", "Component") +#else + #if (!react_global) @:jsRequire("react", "Component") #end @:native('React.Component') +#end + @:keepSub @:autoBuild(react.ReactComponentMacro.build()) extern class ReactComponentOf diff --git a/src/lib/react/ReactDOM.hx b/src/lib/react/ReactDOM.hx index 3131e61..1a9b444 100644 --- a/src/lib/react/ReactDOM.hx +++ b/src/lib/react/ReactDOM.hx @@ -6,10 +6,16 @@ import js.html.Element; /** https://facebook.github.io/react/docs/react-dom.html **/ + +#if (jsImport) +@:js.import(@default "react-dom") +#else + #if (!react_global) @:jsRequire("react-dom") #end @:native('ReactDOM') +#end extern class ReactDOM { /** diff --git a/src/lib/react/ReactDOMClient.hx b/src/lib/react/ReactDOMClient.hx new file mode 100644 index 0000000..012b760 --- /dev/null +++ b/src/lib/react/ReactDOMClient.hx @@ -0,0 +1,23 @@ +package react; + +import js.html.Element; +import react.ReactComponent.ReactElement; + +/** + Note: this API has been introduced in React 18 +**/ + +#if jsImport +@:js.import(@default "react-dom/client") +#else + +#if (!react_global) +@:jsRequire("react-dom/client") +#end + +@:native('ReactDOMClient') +#end +extern class ReactDOMClient { + public static function createRoot(container:Element, ?options:Null):Dynamic; + public static function hydrateRoot(container:Element, children:ReactElement, ?options:Null):Dynamic; +} \ No newline at end of file diff --git a/src/lib/react/ReactDOMServer.hx b/src/lib/react/ReactDOMServer.hx index 7c91eaa..30d1706 100644 --- a/src/lib/react/ReactDOMServer.hx +++ b/src/lib/react/ReactDOMServer.hx @@ -13,10 +13,16 @@ class ReactMarkupReadableStream extends Readable {} /** https://facebook.github.io/react/docs/react-dom-server.html **/ + +#if (jsImport) +@:js.import(@default "react-dom/server") +#else + #if (!react_global) @:jsRequire('react-dom/server') #end @:native('ReactDOMServer') +#end extern class ReactDOMServer { /**