I'm trying to set array using useState feature
function SelectCategoryList() {
const [presentDataArray, setPresentDataArray] = useState([]);
const hello = ['hello', 'bye'];
useEffect(() => {
console.log(hello);
setPresentDataArray([...hello]);
console.log(presentDataArray);
}, []);
}
first console : ['hello', 'bye']
second console : []
Why presentDataArray does not set value by helloArray