Answer the question
In order to leave comments, you need to log in
How to implement data editing?
Hello!
Perhaps the question is stupid, but I could not find a solution to the problem.
The task is to implement the possibility of CRUD operations for the application. C, R, D is already there.
It is necessary to implement the ability to edit and save changes on the server.
I load data from Firebase in the following format:
[
...
{
id: "1",
title: "some title",
number: "1111",
format: "some format",
string: "some string"
}
...
]
export default React.createClass({
dataChanged(newdata) {
this.setState({
data: newdata
});
},
render() {
return (
<div>
<div
<InlineEdit paramName="title" change={this.dataChanged} text={this.props.title} />
<InlineEdit paramName="year" change={this.dataChanged} text={this.props.nubmer} />
<InlineEdit paramName="year" change={this.dataChanged} text={this.props.format} />
<InlineEdit paramName="stars" change={this.dataChanged} text={this.props.string} />
</div>
)
}
})
Answer the question
In order to leave comments, you need to log in
Good afternoon.
Where did you get this.props.title then, for example?
After editing the field (fields), you send a request to the server with the data from the form (by clicking on the button in the parent component, or what?). Use the id that comes to you initially (judging by the data format in your question) and is probably located in this.props.id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question