當道具傳遞給在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
嘿,你是否得到了答案?我遇到了同樣的問題 –