1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| const {Component} = React class Heaven extends Component{ state = { name:'LongShortParty', arr :['html','css','js','node','react'] } render(){ const {arr} = this.state return ( <ul> { arr.map(item=><li key={item}>{item}</li>) } </ul> ) } }
const reverseInherit = (BaseComponent)=>{ return class extends BaseComponent{ render(){ console.log(this.state) return super.render() } } } const Result1 = reverseInherit(Heaven)
ReactDOM.render(<Result1 />,document.getElementById('box'))
|