high-order-react
TypeScript icon, indicating that this package has built-in type declarations

0.3.8 • Public • Published

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
  }
}

docs

Package Sidebar

Install

npm i high-order-react

Weekly Downloads

2

Version

0.3.8

License

none

Unpacked Size

40 kB

Total Files

48

Last publish

Collaborators

  • hooks_28