'How to execute a function after setting a state in React Native?
my problem is I need to execute a function (getCupons) after setting the two states setPagenumber and setMoreresults but this two functions are asynchronous and don't have a callback. Thanks
const [pageNumber, setPagenumber] = useState(1);
const [moreResults, setMoreresults] = useState(true);
const isFocused = useIsFocused();
useEffect(() => {
setPagenumber(1);
setMoreresults(true);
getCupons();
}, [isFocused])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
