I'm building a react/redux app and using a ux library called Grommet in the front end. I have the app set up such that I have a series of forms contained within a set of accordions on the page. Here's a whittled downed version containing only one accordion tab:
handleCpuChange(event) {
console.log(event.target)
this.props.updateStore(
{'general': {'cpus': event.target.value} }
)
}
<Accordion>
<AccordionPanel heading="General">
<Box>
<FormFields>
<FormField label='CPUs'>
<NumberInput
value={this.props.form.formData.general.cpus}
onChange={this.handleCpuChange.bind(this)}/>
</FormField>
<FormField label='Ram'>
<NumberInput
defaultValue={this.props.form.formData.general.ram}
onChange={this.handleCpuChange.bind(this)}/>
</FormField>
</FormFields>
</Box>
</AccordionPanel>
</Accordion>
- All of this works fine. The problem is that when I call the handleCpuChange function is called my state/store value gets updated - but my the actual 'value' or 'defaultValue' fields stay the same. For the most part this is no problem but if I close and reopen the accordion the values in those fields resets to the defaults/values supplied through props. I figured that a nice way around this is to remap the state to props whenever the accordion opens or closes that way the actual value updates - but I'm not sure how to do this without reloading the entire page.