Skip to content

Commit 71c239a

Browse files
Keep useTransition backward compatibility and add startTransition (#142)
* Keep `useTransition` backward compatibility * Add `startTransition`
1 parent 056ce1c commit 71c239a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/React.res

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,23 @@ external displayName: component<'props> => option<string> = "displayName"
411411

412412
// Actions
413413

414-
type transitionFunction = unit => promise<unit>
415-
414+
type transitionFunction = unit => unit
416415
type transitionStartFunction = transitionFunction => unit
417416

417+
type transitionFunctionAsync = unit => promise<unit>
418+
type transitionStartFunctionAsync = transitionFunctionAsync => unit
419+
420+
/** `startTransition` lets you render a part of the UI in the background. */
421+
@module("react")
422+
external startTransition: transitionStartFunction = "startTransition"
423+
@module("react")
424+
external startTransitionAsync: transitionStartFunctionAsync = "startTransition"
425+
418426
/** `useTransition` is a React Hook that lets you render a part of the UI in the background. */
419427
@module("react")
420428
external useTransition: unit => (bool, transitionStartFunction) = "useTransition"
429+
@module("react")
430+
external useTransitionAsync: unit => (bool, transitionStartFunctionAsync) = "useTransition"
421431

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

0 commit comments

Comments
 (0)