Skip to content

Keep useTransition backward compatibility and add startTransition #142

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 12 additions & 2 deletions src/React.res
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,23 @@ external displayName: component<'props> => option<string> = "displayName"

// Actions

type transitionFunction = unit => promise<unit>

type transitionFunction = unit => unit
type transitionStartFunction = transitionFunction => unit

type transitionFunctionAsync = unit => promise<unit>
type transitionStartFunctionAsync = transitionFunctionAsync => unit

/** `startTransition` lets you render a part of the UI in the background. */
@module("react")
external startTransition: transitionStartFunction = "startTransition"
@module("react")
external startTransitionAsync: transitionStartFunctionAsync = "startTransition"

/** `useTransition` is a React Hook that lets you render a part of the UI in the background. */
@module("react")
external useTransition: unit => (bool, transitionStartFunction) = "useTransition"
@module("react")
external useTransitionAsync: unit => (bool, transitionStartFunctionAsync) = "useTransition"

type action<'state, 'payload> = ('state, 'payload) => promise<'state>

Expand Down