Skip to content

Commit d8afd1c

Browse files
authored
[crud] Scaffold initial types (#31555)
Scaffolds the initial `useResourceEffect` dispatcher type. This will eventually be folded into `useEffect` et al as an overload. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31555). * #31523 * #31557 * #31556 * __->__ #31555
1 parent 0480cdb commit d8afd1c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/react-reconciler/src/ReactInternalTypes.js

+8
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export type HookType =
4747
| 'useRef'
4848
| 'useEffect'
4949
| 'useEffectEvent'
50+
| 'useResourceEffect'
5051
| 'useInsertionEffect'
5152
| 'useLayoutEffect'
5253
| 'useCallback'
@@ -412,6 +413,13 @@ export type Dispatcher = {
412413
deps: Array<mixed> | void | null,
413414
): void,
414415
useEffectEvent?: <Args, F: (...Array<Args>) => mixed>(callback: F) => F,
416+
useResourceEffect?: (
417+
create: () => mixed,
418+
createDeps: Array<mixed> | void | null,
419+
update: ((resource: mixed) => void) | void,
420+
updateDeps: Array<mixed> | void | null,
421+
destroy: ((resource: mixed) => void) | void,
422+
) => void,
415423
useInsertionEffect(
416424
create: () => (() => void) | void,
417425
deps: Array<mixed> | void | null,

packages/react/src/ReactHooks.js

+10
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ export function useEffectEvent<Args, F: (...Array<Args>) => mixed>(
226226
return dispatcher.useEffectEvent(callback);
227227
}
228228

229+
export function useResourceEffect(
230+
create: () => mixed,
231+
createDeps: Array<mixed> | void | null,
232+
update: ((resource: mixed) => void) | void,
233+
updateDeps: Array<mixed> | void | null,
234+
destroy: ((resource: mixed) => void) | void,
235+
): void {
236+
throw new Error('Not implemented.');
237+
}
238+
229239
export function useOptimistic<S, A>(
230240
passthrough: S,
231241
reducer: ?(S, A) => S,

0 commit comments

Comments
 (0)