I have a local JSON file which is used for loading all data to app. In one component I load in constructor()
those data. In function addRow()
I add new field but it's just in local state variable. I would like to add it to json file also, so after refresh this new row will be still here.
I was trying find how this solved really easy but I didn't find it. If you know about some topic send it to me.
constructor() {
super();
this.state = {
employees: require('json!../../../data/employees.json')
};
this.addEmployee = this.addEmployee.bind(this);
}
addEmployee(employee) {
this.setState({
employees: this.state.employees.concat([employee])
});
}