Skip to content

Add usePromise for use(promise) #135

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

Merged
merged 1 commit into from
May 3, 2025
Merged
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
3 changes: 0 additions & 3 deletions src/React.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 3 additions & 11 deletions src/React.res
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback =
@module("react")
external useContext: Context.t<'any> => 'any = "useContext"

@module("react")
external usePromise: promise<'a> => 'a = "use"

@module("react") external useRef: 'value => ref<'value> = "useRef"

@module("react")
Expand Down Expand Up @@ -433,17 +436,6 @@ external useActionState: (
external useOptimistic: ('state, ('state, 'action) => 'state) => ('state, 'action => unit) =
"useOptimistic"

module Usable = {
type t<'value>

external context: Context.t<'value> => t<'value> = "%identity"
external promise: promise<'value> => t<'value> = "%identity"
}

/** `use` is a React API that lets you read the value of a resource like a Promise or context. */
@module("react")
external use: Usable.t<'value> => 'value = "use"

/** `act` is a test helper to apply pending React updates before making assertions. */
@module("react")
external act: (unit => promise<unit>) => promise<unit> = "act"