Skip to content

Commit 235bfd0

Browse files
committed
React.use
1 parent 0f04665 commit 235bfd0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/React.res

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,14 @@ external useActionState: (
430430
@module("react")
431431
external useOptimistic: ('state, ('state, 'action) => 'state) => ('state, 'action => unit) =
432432
"useOptimistic"
433+
434+
module Usable = {
435+
type t<'value>
436+
437+
external context: Context.t<'value> => t<'value> = "%identity"
438+
external promise: promise<'value> => t<'value> = "%identity"
439+
}
440+
441+
/** `use` is a React API that lets you read the value of a resource like a Promise or context. */
442+
@module("react")
443+
external use: Usable.t<'value> => 'value = "use"

0 commit comments

Comments
 (0)