I have a component that has another component to return.
var fieldValues = {
firstName : null,
lastName : null,
gender : null,
birthtday : null,
dialingCode: null,
mobileNumber : null,
request_id: null,
textCode : null,
email : null,
password : null,
tagsSelectedList : [],
}
export default class SignUp extends React.Component {
render() {
update
return <SignUpTags
dialingCode = {fieldValues['dialingCode']}
mobileNumber = {fieldValues['mobileNumber']}
requestID = {fieldValues['request_id']}
nextStep={this.nextStep}
saveValues={this.saveValues}
/>
}
}
When I load the page, I get the following errors:
dialingCode
,mobileNumber
andrequestID
are all undefined.
How can I access the object variable's fieds to pass as the props to its child component?
They should be fieldValues['dialingCode']
, fieldValues['mobileNumber']
and fieldValues['requestId']
.
Note the '
's indicating they are key strings and aren't variables .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.