How can you set a predefined value on a Form.Input or Input component in semantic UI react? I've tried passing defaultValue="someVal" as a prop which works. But that doesn't update the value if props change. I tried passing the prop value="someVal" which prepopulates it but blocks any access to edit that field. All keystrokes are ignored. There must be a way to basically do
and still have it update the value when componentWillReceiveProps is triggered?
Here is the input component I'm using
This is the form which uses the Input below as the control https://react.semantic-ui.com/collections/form https://react.semantic-ui.com/elements/input
I have an AutoSaveInput.jsx which essentially renders the input below with an onChange to automatically save each keystroke ( still need to add a debounce ).
<Label basic>{this.props.label}</Label>
<Form.Input
defaultValue={this.props.defaultValue}
disabled={this.props.disabled}
name={this.props.name}
onChange={this.onChange}
error={this.state.isDirty}
/>
The input above works fine initially. However, when new props come in, this.props.label updates fine, but the Form.Input value does not update at all. Instead it still shows the previous value.
Also if I change this to the below, the values do update with new props, but you can't type in the input itself. The cursor just jumps to the end of the input and doesn't let you type anything else.
<Label basic>{this.props.label}</Label>
<Form.Input
value={this.props.defaultValue}
disabled={this.props.disabled}
name={this.props.name}
onChange={this.onChange}
error={this.state.isDirty}
/>
Also the props are being updated via ReactRouter v4 by clicking a Click where the var is what loads in different form content for editing.
onChange((e) => this.state.data.input_name))