Relative Content

Tag Archive for javascriptreactjsnode.jsreact-hooks

React setState not grabbing the correct value (value was rendered twice, setState grabbed the value when it was not done rendering)

I have a const called mappedFilter.
mappedFilter takes a while to populate. It renders the first time missing some objects, and renders the second time with all the objects
I have a setState for allItems for (mappedFilter), but it is grabbing the mappedFilter the first time around with missing objects, not once the mappedFilter has gotten done populating with all the fields.
My code: