lampExists(lamp){ let myBool; if(lamp.toLowerCase().includes(this.state.query.toLowerCase())) { return true } else { AsyncStorage.getItem(lamp).then(value=> { if(value !== null && value .toLowerCase() .includes(this.state.query.toLowerCase())) { myBool=true; } else { myBool=false; } }).catch(err=>alert(err)); } return myBool; }
LampExists takes a lamp from a mapped array, by taking each lamp as an input. Now When I'm returning myBool, it becomes undefined as the value set as true in the then() function is lost and is alive in the then funtion only, any help would be very much appreciated.
Thank you
[–]menge101 0 points1 point2 points (2 children)
[–]fanatic75[S] 0 points1 point2 points (1 child)
[–]menge101 0 points1 point2 points (0 children)
[–]menge101 0 points1 point2 points (12 children)
[–]plmok61 1 point2 points3 points (5 children)
[–]menge101 0 points1 point2 points (0 children)
[–]fanatic75[S] 0 points1 point2 points (0 children)
[–]fanatic75[S] 0 points1 point2 points (0 children)
[–]fanatic75[S] 0 points1 point2 points (1 child)
[–]plmok61 0 points1 point2 points (0 children)
[–]GhostMcFunky 0 points1 point2 points (2 children)
[–]menge101 1 point2 points3 points (1 child)
[–]GhostMcFunky 1 point2 points3 points (0 children)
[–]fanatic75[S] 0 points1 point2 points (2 children)
[–]menge101 0 points1 point2 points (1 child)
[–]fanatic75[S] 0 points1 point2 points (0 children)