useRefState
Creates a ref-like state that updates on assignment.
Usage
import { useRefState } from "@siberiacancode/reactuse";
const ref = useRefState();Example
initialValue:
const ref = useRefState(0);
return <button onClick={() => ref.current += 1;}>Increment {ref.current}</button>;Type Declarations
export interface StateRef<Value> {
(node: Value): void;
current: Value;
state?: Value;
}
export declare const useRefState: <Value>(
initialValue?: Value
) => StateRef<Value>;