Objective Redux

Redux made better, objectively.

useSelector

function useSelector<T>(selectorFn: (state: any) => T): any

Gets a selection of the state from the store.

Template Parameters

<T>

Parameters

selectorFn: (state: any) => T
A selector/mapping function used to select values out of the state.

Returns

any
The selected piece of state from the store.

Examples

import React from 'react';
import { useSelector } from 'objective-redux';

export function MyFunctionalComponent() {
  const { isOn } = useSelector(state => ({ isOn: state.switch.isOn }));

  return <p>Switch is { isOn ? 'On' : 'Off' }</p>;
}