useGetState
Add a getter method to the return value of React.useState to get the latest value
Overview
Add a getter method to the return value of React.useState to get the latest value
Installation
Open inpnpm dlx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useGetState.jsonnpx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useGetState.jsonyarn shadcn@latest add https://shadcn-ahooks.vercel.app/r/useGetState.jsonbun shadcn@latest add https://shadcn-ahooks.vercel.app/r/useGetState.jsonAdd a getter method to the return value of React.useState to get the latest value
Examples
Default usage
TypeScript definition
import { Dispatch, SetStateAction } from 'react';
type GetStateAction<S> = () => S;
function useGetState<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>, GetStateAction<S>];
function useGetState<S = undefined>(): [S | undefined, Dispatch<SetStateAction<S | undefined>>, GetStateAction<S | undefined>];API
const [state, setState, getState] = useGetState<S>(initialState)useFusionTable
useFusionTable encapsulates the commonly used [Fusion Form](https://fusion.design/pc/component/basic/form) and [Fusion Table](https://fusion.design/pc/component/basic/table) data binding logic.
useHistoryTravel
A hook to manage state change history. It provides encapsulation methods to travel through the history.