I was wondering why I get an empty array despite I've used setCategory but If I print (res.data.category), there are data inside this.
If you know anything about this, Thanks for your help.
const [category, setCategory] = useState([]);
var listItems = '';
useEffect(() => {
axios.get(`/api/getCategory`).then(res => {
if (res.data.status === 200) {
setCategory(res.data.category);
console.log(res.data.category);
}
});
}, []);