Context特性
若组件多层包裹 且外层属性或方法要传递给内层的组件 则传递会变得比较麻烦
比如:
import React from 'react';
export default class Parent extends React.Component {
constructor(props) {
super(props);
this.state = {
mycolor:"red"
}
}
render() {
return <div>
<h1>I'm Parent</h1>
<Son mycolor={
this.state.mycolor}></Son>
</div>