My code looks something like this
componentWillMount(){
lotGroups = // backend call to fetch lotgroups
setState({
lotGroups
)};
}
As I am changing lotGroups later on (using setState only) I wanted to store the initial copy of the complete set of lotGroups. What would be the best way? I tried adding that variable to state and then updating it in componentWillMount(), but it did not work. As soon as the lotGroups updated, this got updated too.