-
Notifications
You must be signed in to change notification settings - Fork 44
React 18 support #35
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
React 18 support #35
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -370,6 +370,60 @@ external useImperativeHandle7: ( | |
('a, 'b, 'c, 'd, 'e, 'f, 'g), | ||
) => unit = "useImperativeHandle" | ||
|
||
@module("react") external useId: unit => string = "useId" | ||
|
||
@module("react") external useDeferredValue: 'value => 'value = "useDeferredValue" | ||
|
||
@module("react") | ||
external useTransition: unit => (bool, (. unit => unit) => unit) = "useTransition" | ||
|
||
@module("react") | ||
external useInsertionEffect: (@uncurry (unit => option<unit => unit>)) => unit = | ||
"useInsertionEffect" | ||
@module("react") | ||
external useInsertionEffect0: (@uncurry (unit => option<unit => unit>), @as(json`[]`) _) => unit = | ||
"useInsertionEffect" | ||
@module("react") | ||
external useInsertionEffect1: (@uncurry (unit => option<unit => unit>), array<'a>) => unit = | ||
"useInsertionEffect" | ||
@module("react") | ||
external useInsertionEffect2: (@uncurry (unit => option<unit => unit>), ('a, 'b)) => unit = | ||
"useInsertionEffect" | ||
@module("react") | ||
external useInsertionEffect3: (@uncurry (unit => option<unit => unit>), ('a, 'b, 'c)) => unit = | ||
"useInsertionEffect" | ||
@module("react") | ||
external useInsertionEffect4: (@uncurry (unit => option<unit => unit>), ('a, 'b, 'c, 'd)) => unit = | ||
"useInsertionEffect" | ||
@module("react") | ||
external useInsertionEffect5: ( | ||
@uncurry (unit => option<unit => unit>), | ||
('a, 'b, 'c, 'd, 'e), | ||
) => unit = "useInsertionEffect" | ||
@module("react") | ||
external useInsertionEffect6: ( | ||
@uncurry (unit => option<unit => unit>), | ||
('a, 'b, 'c, 'd, 'e, 'f), | ||
) => unit = "useInsertionEffect" | ||
@module("react") | ||
external useInsertionEffect7: ( | ||
@uncurry (unit => option<unit => unit>), | ||
('a, 'b, 'c, 'd, 'e, 'f, 'g), | ||
) => unit = "useInsertionEffect" | ||
|
||
@module("react") | ||
external useSyncExternalStore: ( | ||
@uncurry (unit => @uncurry (unit => unit)), | ||
@uncurry unit => 'state, | ||
) => 'state = "useSyncExternalStore" | ||
|
||
@module("react") | ||
external useSyncExternalStoreWithServerSnapshot: ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can bikeshed the name, it's a tricky one. The alternative could be to name the parameters so that we can have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is interesting to me because there are a bunch of potential future arguments - useSyncExternalStoreWithSelector in the discussion gets wildly long and adding an option to get named optional arguments means it could break in the future if those args get upstreamed into the React export. I think your naming make sense and is probably the safest way to work with these at least until there's more stability for 18 and we see how folks actually use this hook. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think one option could even be to leave the uSES hooks out for the time being. These hooks I expect to not be very prevalent at all in userland code, but I could be wrong 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd name the arguments, as there are two |
||
@uncurry (unit => @uncurry (unit => unit)), | ||
@uncurry unit => 'state, | ||
@uncurry unit => 'state, | ||
) => 'state = "useSyncExternalStore" | ||
|
||
module Uncurried = { | ||
@module("react") | ||
external useState: (@uncurry (unit => 'state)) => ('state, (. 'state => 'state) => unit) = | ||
|
@@ -436,14 +490,6 @@ module Uncurried = { | |
) => callback<'input, 'output> = "useCallback" | ||
} | ||
|
||
type transitionConfig = {timeoutMs: int} | ||
|
||
@module("react") | ||
external useTransition: ( | ||
~config: transitionConfig=?, | ||
unit, | ||
) => (callback<callback<unit, unit>, unit>, bool) = "useTransition" | ||
|
||
@set | ||
external setDisplayName: (component<'props>, string) => unit = "displayName" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,20 +10,20 @@ | |
external querySelector: string => option<Dom.element> = "document.querySelector" | ||
|
||
@module("react-dom") | ||
@deprecated("ReactDOM.render is no longer supported in React 18. Use createRoot instead.") | ||
external render: (React.element, Dom.element) => unit = "render" | ||
|
||
module Experimental = { | ||
type root | ||
module Root = { | ||
type t | ||
|
||
@module("react-dom") | ||
external createRoot: Dom.element => root = "createRoot" | ||
@send external render: (t, React.element) => unit = "render" | ||
|
||
@module("react-dom") | ||
external createBlockingRoot: Dom.element => root = "createBlockingRoot" | ||
|
||
@send external render: (root, React.element) => unit = "render" | ||
@send external unmount: (t, unit) => unit = "unmount" | ||
} | ||
|
||
@module("react-dom") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be react-dom/client. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cknitt I addressed this in the followup PR #46 which has been sitting in limbo for 2 months. I suggest we merge this PR and then open #46 for review, or maybe @tom-sherman can "steal" the commits in #46 and include them in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whatever works, just need a maintainer to get the ball rolling! @rickyvetter Pls 🙏 |
||
external createRoot: Dom.element => Root.t = "createRoot" | ||
|
||
@module("react-dom") | ||
external hydrate: (React.element, Dom.element) => unit = "hydrate" | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.