Skip to content

Commit a3f5aab

Browse files
committed
Documentation
1 parent 1e9a4bb commit a3f5aab

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

packages/@react-facet/core/src/hooks/useFacetTransition.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { useTransition, useCallback } from 'react'
22
import { Batch } from '../types'
33
import { batchTransition } from '../scheduler'
44

5+
/**
6+
* Hook that acts analogous to React's useTransition, ensuring that any React state change that happens as a
7+
* result of a Facet update is handled within a React transition.
8+
*/
59
export const useFacetTransition = (): [boolean, (fn: () => void) => void] => {
610
const [isPending, reactStartTransition] = useTransition()
711

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { startTransition as reactStartTransition } from 'react'
22
import { batchTransition } from './scheduler'
33

4+
/**
5+
* API that acts analogous to React's startTransition, ensuring that any React state change that happens as a
6+
* result of a Facet update is handled within a React transition.
7+
*/
48
export const startFacetTransition = (fn: () => void) => {
59
reactStartTransition(() => batchTransition(fn))
610
}

0 commit comments

Comments
 (0)