Reactjs 无法读取属性';道具';使用MapStateTops返回null
您好,我开始对redux和redux传奇进行本地响应,目前我需要通过ajax将cities数组加载到一个选择器,这是我到目前为止的代码 内部渲染方法:Reactjs 无法读取属性';道具';使用MapStateTops返回null,reactjs,properties,null,redux,native,Reactjs,Properties,Null,Redux,Native,您好,我开始对redux和redux传奇进行本地响应,目前我需要通过ajax将cities数组加载到一个选择器,这是我到目前为止的代码 内部渲染方法: render() { if (this.props.loaded) { // } return ( <ContainerScroll> <StatusBar translucent={false} barStyle="light-content" /> <Section style={{
render() {
if (this.props.loaded) {
//
}
return (
<ContainerScroll>
<StatusBar translucent={false} barStyle="light-content" />
<Section style={{ height: deviceHeightOneThird }}>
<LabelScreenHeader text={I18n.t('signupEmailHeaderLabel')} />
</Section>
<Section>
<TextInputDefault
label={I18n.t('signupEmailInputLabel')}
keyboardType="email-address"
onChangeText={email => this.setState({ email })}
value={this.state.email}
placeholder={I18n.t('signupEmailInputPlaceHolder')}
/>
<TextInputDefault
label={I18n.t('signupPhoneNumberInputLabel')}
keyboardType="numeric"
onChangeText={phoneNumber => this.setState({ phoneNumber })}
value={this.state.phoneNumber}
placeholder={I18n.t('signupPhoneNumberInputPlaceHolder')}
/>
<TextInputDefault
label={I18n.t('signupNameInputLabel')}
keyboardType="default"
onChangeText={name => this.setState({ name })}
value={this.state.name}
placeholder={I18n.t('signupNameInputPlaceHolder')}
/>
<TextInputDefault
label={I18n.t('signupPasswordInputLabel')}
keyboardType="default"
onChangeText={password => this.setState({ password })}
value={this.state.password}
secureTextEntry
placeholder={I18n.t('signupPasswordInputPlaceHolder')}
/>
<PickerDefault
iosHeader={I18n.t('signupCityDropdownDefaultValue')}
selectedValue={this.state.cityPickerValue}
onValueChange={city => this.setState({ cityPickerValue: city })}
>
{console.log('this.props ---- ', this.props.cities) /* this is where error pop up when calling cities*/}
<Picker.Item label={I18n.t('signupCityDropdownDefaultValue')} value="default" />
{this.displayCities}
</PickerDefault>
<Button
buttonText={I18n.t('signupEmailButtonText')}
onPress={this.handleSignUp}
wrapperStyleProp={{
marginTop: 30,
}}
/>
</Section>
</ContainerScroll>
);
}
在jsx标记中调用this.props时出错。例如,这一行
{console.log('this.props ---- ', this.props.cities)
我有点自学,对redux和redux传奇有点反应。所以,如果这是新手的话,请容忍我
谢谢大家您是如何创建组件的?把它包括在你的问题中<代码>类Blah扩展组件或
React.createClass()
?请发布您的错误以及缩减器。:)请张贴完整的组件。您还可以在mapStateToProps
内控制台日志,查看是否设置了state.commonDataReducer.cities
。
{console.log('this.props ---- ', this.props.cities)