我正在尝试使用useState功能设置数组
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 : []
为什么presentDataArray不能通过helloArray
设置值