this.state = {
name: '',
color: '',
description: '',
beacons: []
};
handleColors = (item) => {
this.setState({
color: item.value
});
};
handleBeaconChange = (beacons) => {
this.setState({
beacons
});
};
handleInputChange(event) {
this.setState({
[event.target.name]: event.target.value
});
}
<div className="mb-1 margin-input">
<span className=" form-font div-width">NAME<span className="font-css top">*</span></span>
<input type="text"
className="form-control margin-select"
placeholder="Name"
value={this.state.name}
name="name"
onChange={this.handleInputChange}
/>
</div>
<div className="mb-1">
<span className=" form-font div-width">
COLOR</span>
<Select
className="margin-select"
value={this.state.color}
options={colorValues}
onChange={this.handleColors}/>
</div>
<div className="mb-1 margin-input">
<span className=" form-font div-width">DESCRIPTION</span>
<textarea
className="form-control margin-select"
placeholder="Description"
value={this.state.description}
name="description"
onChange={this.handleInputChange}
/>
</div>
<h3 className="">{this.props.label}</h3>
<div className="mb-1">
<span className=" form-font div-width">
BEACON (s)</span>
<Select.Async
multi={true}
className="margin-select"
value={this.state.beacons}
loadOptions={getBeacons}
onChange={this.handleBeaconChange}/>
<div className="panel-body">
<a href={'/new-beacon'} className="pull-right">Add Beacon</a>
</div>
</div>
This is the image.
Now i just wanted to save previous form data before going to another page
Like for example in this picture i had entered name and color values in the fields and when i click on "Add beacon link", it will route me to another form but the values i entered in this form were lost when i will come back to it.
Any solutions regarding that?