Skip to main content

useSimpleStateValue

Overview

Type: Function

A React hook to consume a SimpleStateManager.

const state = useSimpleStateValue(stateManager)
Overloads (+2)
const state = useSimpleStateValue(stateManager, selector)
const state = useSimpleStateValue(stateManager, selector, active)

Parameters

  • stateManagerThe State Manager to watch for changes.
    Type: SimpleStateManager
    Required: Yes
  • selectorA function that accepts the state as an argument and returns a derived value. This function does not need to be declared outside of the component function body or wrapped in useCallback.
    Type: StateSelector
    Required: No — (default value: null)
  • activeControls whether the hook should watch for state changes and trigger component update.
    Type: boolean
    Required: No — (default value: true)

Examples

Basic

With selector

Conditionally watch for changes