I've setItem in Home.js file as:
AsyncStorage.setItem('myValue', JSON.stringify(3))
Now in another file called Ask.js I've a button where I'm calling it:
const [val, setVal] = useState("1");
...
<TouchableOpacity onPress={() => {
AsyncStorage.getItem("myValue").then((value) => {
setVal(value)
console.log(value + ' and ' + val)
});
}}>
Based on the console.log When this button is pressed it logs 1 and 3 which seems like the value is not updated but if I press it again it'll print 3 and 3 which means the useState value was updated but it didn't rerender.
So how do I re-render?