UseEffect doesn’t work in React Native

Share on facebook
Share on google
Share on twitter
Share on linkedin


I have installed axios in order to perform a basic get request to an API. To this purpose, I use React's useEffect:

export default function Home() { const [poke, setPoke] = useState([]); useEffect(() => { axios.get("") .then(res => setPoke( .catch(err => console.log(err)); }, []); 

The useEffect is called when the component mounts (I've removed all the consol.log for more clarity), but nothing happens afterwards. Nor then nor catch are called. Is there something wrong with my script or is useEffect not allowed in React Native?


submitted by /u/MonsieurLeland
[link] [comments]

Sign up for our Newsletter

Agree to our privacy policy.