Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented StrictMode into Haxe-React, and possibly more #147

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/lib/react/React.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,6 +66,13 @@ extern class React
public static function forwardRef<TProps, TRef>(render:TProps->ReactRef<TRef>->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
**/
Expand Down
6 changes: 6 additions & 0 deletions src/lib/react/ReactComponent.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ typedef ReactComponentOfState<TState> = ReactComponentOf<Empty, TState>;
// Keep the old ReactComponentOfPropsAndState typedef available a few versions
typedef ReactComponentOfPropsAndState<TProps, TState> = ReactComponentOf<TProps, TState>;

#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<TProps, TState>
Expand Down
6 changes: 6 additions & 0 deletions src/lib/react/ReactDOM.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand Down
23 changes: 23 additions & 0 deletions src/lib/react/ReactDOMClient.hx
Original file line number Diff line number Diff line change
@@ -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>):Dynamic;
public static function hydrateRoot(container:Element, children:ReactElement, ?options:Null<Dynamic>):Dynamic;
}
6 changes: 6 additions & 0 deletions src/lib/react/ReactDOMServer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ class ReactMarkupReadableStream extends Readable<ReactMarkupReadableStream> {}
/**
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
{
/**
Expand Down