Answer the question
In order to leave comments, you need to log in
Duplicate variable in ReactJs?
Good afternoon! Did a search for notes on ReactJs. The bottom line is that the data is stored in localstorage, it cannot be filtered because it immediately saves the filtered array and deletes the elements, so I duplicate the array with data and work with it, but in this way I need to update the array with each state change (there is a deletion and adding an element). Please tell me how to do this correctly, bypass the duplication of a variable with an array at each state change? Perhaps there is a component designed for this, I can not figure it out ..
Many thanks in advance)
Answer the question
In order to leave comments, you need to log in
If you are new to React, and only one component uses this data, then I think redux and others are superfluous. I advise you to do this: the parent, which is a storage for data, and writes / reads localStorage. And there is a component in it, to which data is given, and it already deals with filtering.
componentWillUpdate(props) {
this.filterNotes(props.notes);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question