State variable does not change inside useEffect – React native
In the following useEffect, data is fetched and is logged successfully: const [allBooks, setAllBooks] = useState([]); useEffect(() => { axios.get('/all_books').then(res => { setAllBooks(res.data); console.log(res.data) //console.log(allBooks) }).catch(error => { console.log(error); }); }, []); //... return( {allBooks.length > 0 ? ( <div…