Skip to content

Latest commit

 

History

History
36 lines (30 loc) · 581 Bytes

selector.md

File metadata and controls

36 lines (30 loc) · 581 Bytes
id title
selector
selector()

function to select state for a given state path.

selector(storeRootState, statePath)

Returns Redux state for the given path

Example

import {useEffect} from 'react'
import useReduxState, {selector} from 'use-redux-states'

const Component = () => {
  useReduxState({
    state: {
      state1: 'a',
      state2: 'b',
    },
    path: 'component_state'
  })

  useEffect(() => {
    selector(
      store.getState(),
      'component_state',
    )
    // component_state {state1: 'a', state2: 'b'}
  }, [])
}