UNPKG

reshow-return

Version:

reshow-return (simple connect component with reshow-flux)

56 lines (52 loc) 1.35 kB
// @ts-check import { useConnect } from "reshow-flux"; import connectOptions from "./connectOptions.mjs"; /** * @template StateType * @template ActionType * * @typedef {import("./connectOptions").calculateOptions<StateType, ActionType>} calculateOptions */ /** * @typedef {object} UseReturnPayLoad * @property {{[key: string]: string[]}} [pathStates] * @property {boolean} [immutable] * @property {boolean} [renewProps] * @property {function({prev:any, nextProps:any, nextState:any}):boolean} [shouldComponentUpdate] */ /** * @template StateType * @template ActionType * * @callback UseReturnType * @param {import('./connectOptions').InitStatesType?} initStates * @param {import("reshow-flux-base").StoreObject<StateType, ActionType>} store * @param {UseReturnPayLoad} [payload] * * @returns {StateType} */ /** * @type UseReturnType<any, any> */ var useReturn = function useReturn(initStates, store, _temp) { var { pathStates, renewProps, shouldComponentUpdate, immutable = true } = _temp === void 0 ? {} : _temp; /** * @type {calculateOptions<any, any>&UseReturnPayLoad} */ var options = { initStates, store, pathStates, immutable, renewProps, shouldComponentUpdate }; var state = useConnect(connectOptions)(options); return state; }; export default useReturn;