import {Component} from "react"; // Deprecated export type SetState = (state) => void interface State { } interface StateProps { state: State setState: SetState } export function redirectState

(thisComponent: Component, innerStatePropName: keyof P['state']) { return { state: thisComponent.props.state[innerStatePropName] } } export function handleSetSate

(thisComponent: Component, innerStatePropName: keyof P['state']) { return function (pageStateAssign) { const stateElement = thisComponent.props.state[innerStatePropName] as any; const innerState = {...stateElement, ...pageStateAssign} thisComponent.props.setState({...thisComponent.props.state as any, [innerStatePropName]: innerState}) } } export function handleTopSetState

(thisComponent: Component, innerStatePropName: keyof S) { return function (innerStateAssign) { const stateElement = thisComponent.state[innerStatePropName] as any; const innerState = {...stateElement, ...innerStateAssign} thisComponent.setState({...thisComponent.state as any, [innerStatePropName]: innerState}) } }