Function useCleanState

Creates a state object, which includes the provided values, as well as helper methods for updating those values and automatically rerendering your component's UI to reflect the updates.

Uses React.useState under the hood, with a separate call to useState for each top-level key in the provided object.

Discussion: When to useCleanState.

  • Type Parameters

    • TInit extends StateInit

    Parameters

    • _initialState: TInit
    • ...props: TInit extends (...args: TProps) => TState ? TProps : []

    Returns TCleanState<TInitialState<TInit>>