【发布时间】:2020-12-17 18:13:10
【问题描述】:
如果我有这样定义的组件:
export default class LinkContainer extends React.Component {
render() {
return (
<div>
<a href={this.props.baselink}>
<h3>{this.props.title}</h3>
</a>
{this.props.children}
</div>
)
}
}
有没有办法将this.props.baselink 传递给this.props.children 中的所有组件?
【问题讨论】:
-
一种选择是使用上下文:reactjs.org/docs/context.html
标签: reactjs components react-props children