Skip to content

Commit 9bd9556

Browse files
committed
keep useTransition for sync and add an useTransitionAsync
this allows to remove a breaking change from v0.14.0
1 parent 056ce1c commit 9bd9556

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/React.res

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,22 @@ external displayName: component<'props> => option<string> = "displayName"
411411

412412
// Actions
413413

414-
type transitionFunction = unit => promise<unit>
414+
type transitionFunction = unit => unit
415415

416416
type transitionStartFunction = transitionFunction => unit
417417

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

422+
type transitionAsyncFunction = unit => promise<unit>
423+
424+
type transitionAsyncStartFunction = transitionAsyncFunction => unit
425+
426+
/** `useTransitionAsync` is a React Hook that lets you render a part of the UI in the background. */
427+
@module("react")
428+
external useTransitionAsync: unit => (bool, transitionAsyncStartFunction) = "useTransition"
429+
422430
type action<'state, 'payload> = ('state, 'payload) => promise<'state>
423431

424432
type formAction<'formData> = 'formData => promise<unit>

0 commit comments

Comments
 (0)