Appearance
@shtse8/fluxus / react-adapter / useProviderUpdater
Function: useProviderUpdater()
useProviderUpdater<
T>(provider): (newValueOrFn) =>void
Defined in: react-adapter/hooks.ts:124
A React hook that returns the updater function for a StateProviderInstance.
This hook allows components to update the state of a StateProvider without needing to subscribe to its value (and thus avoiding re-renders when the value changes if the component doesn't display it).
The returned function has a stable identity across re-renders as long as the provider and scope remain the same, making it safe to use in dependency arrays of other hooks like useEffect or useCallback.
Must be used within a ProviderScope.
Type Parameters
T
T
The type of the state managed by the StateProvider.
Parameters
provider
The StateProvider instance whose updater is needed.
Returns
A stable function to update the provider's state.
(
newValueOrFn):void
Parameters
newValueOrFn
T | (prev) => T
Returns
void
Throws
If used outside of a ProviderScope.
Throws
If the provider is not a valid, initialized StateProvider in the scope.