I have a Redux form on a page that is for user profile data. This page has locaton options for state and city as option boxes. When the user selects a value, I get the ID of the item in the array and then store that to the DB. When the user goes back to the profile page, how do I set the state and city that was previously saved do they would see the proper state and city on the page? For example, if New Your was saved as the state, that is what the user should see when entering the page.
I have tried setting the value, text, field...nothing seems to work.
return await restAPI.get('/api/customers/profiles/me', currentUser.id).then(userProfile => {
this.setState ({
firstName: userProfile.firstName,
lastName: userProfile.lastName,
companyPhone : userProfile.companyPhone,
cellPhone : userProfile.cellPhone,
email: userProfile.email,
age: userProfile.age,
asset: userProfile.asset,
birthday: userProfile.birthday,
city: userProfile.cityId,
role: userProfile.role,
state: userProfile.stateId
})
});
<Field
component={this.selectComponent}
name="state"
id="state"
onChange={(e, newValue) =>this.handleStateChange(e, newValue)}
>
{this.state.states.map((state, i) => (
<option key={i} value={state}>
{" "}
{state}{" "}
</option>
))}
</Field>