Closed AkalUstat closed 4 years ago
This bug is much more complex than previously expected, moving up in prioroity. Aim to have done by this weekend
Debugging reveals 3 things:
Culprits:
AddToGutka = (entryid, entrytype) => { const newObj = { id: entryid, type: entrytype } const allGutkas = this.state.gutkas; allGutkas.find(g => g.name === this.state.currentGutkaName).items = [...this.state.currentGutka, newObj]; this.setState(prevState => ({ currentGutka: [...prevState.currentGutka, newObj] })) AsyncStorage.setItem(
${GUTKAS_KEY}, JSON.stringify(allGutkas)); }
and
updateCurrentGutka = (newGutka) => this.setState({ currentGutkaName: newGutka });
also gets attempt to spread unspreadable instance
Ok problem with code is that solution that came up in debugging is trying to spread an object: https://stackoverflow.com/questions/53991403/typeerror-invalid-attempt-to-spread-non-iterable-instance
also try to use this, as it may also be causing problems in createGutka
and addToGutka
(from fetchGutkas):
const filteredItems = _.values(normalized.find(gutka => gutka.name === currGutka).items); this.setState({ isDataReady: true, gutkas: normalized, currentGutkaName: currGutka, currentGutka: filteredItems });
Also just create a find current gutka method so i don't have repetitive code (and just have a state modifier functions list
Try to finish today
Upon further contemplation, instead of rewriting once and then rewriting again, finish with #21 #19
Final conclusion: resultant of reassigning to diff object type. Fixing with type declarations...can reinstate flatlist
Possible fix: use map instead of flatlist (its not updating correctly)
Or realm may fix this