使用reactjs在组件之间传递数据
我有一个像下面这样的部门使用reactjs在组件之间传递数据,reactjs,components,Reactjs,Components,我有一个像下面这样的部门 <div className="horiz_center" onClick={this.textType.bind(this,'text')}> <img src={StarIcon} className="post_type_icon"/> <a className="post_type_text">Text</a> </div> 我的问题是,如果我想在另一个组件中使用postType,如何将其
<div className="horiz_center" onClick={this.textType.bind(this,'text')}>
<img src={StarIcon} className="post_type_icon"/>
<a className="post_type_text">Text</a>
</div>
我的问题是,如果我想在另一个组件中使用
postType
,如何将其传递给该组件?您可以使用props
来实现这一点。多读点
const {postType} = this.state;
<MyComponent postType={postType} />
const {postType} = this.state;
<MyComponent postType={postType} />
this.props.postType