useController
function useController<C>(controller: Controller|ModelConstructor<C>, selectorFn: (state: any) => any = (state: any): any => state): C|null
Gets a controller from the ObjectiveStore using hook.
Template Parameters
TypeScript.
Parameters
Returns
context.
Examples
import React from 'react';
import { useController } from 'objective-redux';
import { SwitchStateController } from './switch-state-controller';
export function MyFunctionalComponent() {
const switchStateController = useController(SwitchStateController);
const { isOn } = switchStateController.getStateSlice();
return <p>Switch is { isOn ? 'On' : 'Off' }</p>;
}