79291798

Date: 2024-12-18 16:31:43
Score: 0.5
Natty:
Report link

Turns out the issue was related to boxes and recipes not yet being populated through useEffect as I was trying to set the box after navigating. The solution was to add a dependency on these two states and setting the box only if these two have been set.

    useEffect(() => {
    if (state != undefined && boxes.length > 0 && recipes.length > 0) {
        updateBox(state.barcode)
    }
}, [state, boxes, recipes]);
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Andreas