Last active
April 13, 2024 20:36
-
-
Save pshaddel/526d80ab045d998e7574c8d40956d656 to your computer and use it in GitHub Desktop.
Mount State Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mountState<S>( | |
initialState: (() => S) | S, | |
): [S, Dispatch<BasicStateAction<S>>] { | |
const hook = mountStateImpl(initialState); | |
const queue = hook.queue; | |
const dispatch: Dispatch<BasicStateAction<S>> = (dispatchSetState.bind( | |
null, | |
currentlyRenderingFiber, | |
queue, | |
): any); | |
queue.dispatch = dispatch; | |
return [hook.memoizedState, dispatch]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment