Skip to content

Commit fddcca6

Browse files
committed
React.useActionState
1 parent 16b11dc commit fddcca6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/React.res

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,3 +413,15 @@ type transitionStartFunction = transitionFunction => unit
413413
/** `useTransition` is a React Hook that lets you render a part of the UI in the background. */
414414
@module("react")
415415
external useTransition: unit => (bool, transitionStartFunction) = "useTransition"
416+
417+
type action<'state, 'payload> = ('state, 'payload) => promise<'state>
418+
419+
type formAction<'formData> = 'formData => promise<unit>
420+
421+
/** `useActionState` is a Hook that allows you to update state based on the result of a form action. */
422+
@module("react")
423+
external useActionState: (
424+
action<'state, 'payload>,
425+
'state,
426+
~permalink: string=?,
427+
) => ('state, formAction<'payload>, bool) = "useActionState"

0 commit comments

Comments
 (0)