为了复用,
一定程度上减少了父子通信
父:
import React, { Component } from 'react'
export default class App extends Component {
render() {
return (
<div>
<Child>
<div>11111111111111</div>
<div>22222222222222</div>
</Child>
</div>
)
}
}
子:
class Child extends Component {
render() {
return (
<div>
Child
{this.props.children[1]}
{this.props.children[0]}
</div>
)
}
}
相关作者
- 获取点赞0
- 文章阅读量264
评论()