J
J
Junior Bee2016-09-19 09:21:57
JavaScript
Junior Bee, 2016-09-19 09:21:57

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

2 answer(s)
A
Anton, 2016-09-19
@bee2015

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);
}

A
Anton Izmailov, 2016-09-19
@WapGeaR

Use datastores, I recommend looking at redax

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question