当道具传递给在Redux的特定组件所以我有这个组件中,我使用地图功能调用另一个组件:如何迭代
class configstepper extends React.Component {
...
//in render
if(this.props.selected_devices){
return(
this.props.selected_devices.map((row, index) => (
<DeviceProps key={index} row={row} index={index} />
)))}
...}
现在我DeviceProps组件中获取数据,因此具有道具来呈现 我的问题是我想要的道具要具体到每个DeviceProps不是所有的人:
class deviceProperties extends Component {
...
//in render
<RaisedButton style={styles.Button}label="Read From Device" primary={true} onClick={this.handleRead.bind(this)}/>
<TextField id={this.props.index} value={this.props.read_data} readOnly/>
...
//handleRead where i trigger the action
handleRead(){
this.props.read_device()
}
//mapstate to props
function mapStateToProps(state){
return {
read_data:state.config.test}}
connect(mapStateToProps,actions)(deviceProperties)
数据是按键点击获取当我使所有DeviceProps组件获得相同的数据,同时我只想在点击的组件上获得它ENT。 我想不出围绕这一
请提高您的描述。 DeviceProps与'deviceProperties'相同吗?如何应用mapStateToProps?什么?分享DeviceProps的全部实施。 –
是deviceProperties是DeviceProps我的不好 我修改了我的代码我希望它更清楚 – safouman
嘿,你是否得到了答案?我遇到了同样的问题 –