Package Exports
- high-order-react
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (high-order-react) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Developing react with AOP
install
yarn add high-order-react
or
npm i --save-dev high-order-react
import {
componentDidMount,
initialState,
computedProps,
injectState,
defaultProps
} from "high-order-react";
interface ownState {
age: number;
}
interface ownProps {
height: number;
long: number;
total?: number
}
@componentDidMount(({ age }) => {
console.log(age);
})
@computedProps({ total: ({ height, long }) => height + long })
@defaultProps({
height:10,
long:10
})
@initialState({
age: 1,
})
class App extends Component<ownProps, ownState> {
@injectState(true);
showTime(state?: ownState,props?: ownProps) {
return state.age + props.total
}
render() {
return <h1>wow!{this.showTime()}</h1>; // wow! 21
}
}