import isArray from "lodash/isArray" ; import isEqual from "lodash/isEqual" ; import pick from "lodash/pick" ; import { useSelector } from "react-redux" ; import { Struct } from "helpers/Struct" ; interface ReduxState { [ key ] : any ; } param { string [ ] } stateProps returns { object } export function useRedux < T = { } > ( propsOrFirstProp , ... otherProps ) { return Struct < T > ( useSelector ( ( state ) => { if ( isArray ( propsOrFirstProp ) ) { return pick ( state , propsOrFirstProp ) ; } return pick ( state , [ propsOrFirstProp , ... otherProps ] ) ; } , isEqual ) ) ; }