Skip to main content

# useStateSelector()

    function useStateSelector<TState, Selected>(
       selectStateFieldFunc: SelectStateFieldFunction<TState, Selected>,
       fieldName: string | string[],
       opts: UseStateSelectorOptions<Selected>): Selected;

Generic selector that receives a field selector function returned from getSelectField

## Type Parameters​

### TState​

`TState` = `unknown`

### Selected​

`Selected` = `unknown`

## Parameters​

### selectStateFieldFunc​

`SelectStateFieldFunction`<`TState`, `Selected`>

the store state's field selector function

     // reducer.js
    import { getSelectField } from 'elliemae/pui-app-sdk';

    const name = 'someState';
    export selectStateFieldFunc = getSelectField(name);

### fieldName​

the state's field you want to acccess, this accepts nested objects access, like so 'rootObj.childObj.field'

`string` | `string`[]

### opts​

`UseStateSelectorOptions`<`Selected`> = `{}`

options (defaultValue, equalityFn)

## Returns​

`Selected`

## See​

/lib/api/helpers.ts#getSelectField