我目前正在学习 React。
我可以在函数组件中使用“let”而不是“useState”吗?
const Func = () => {
let fruit = "banana";
const changeFruit = () => {
fruit = "apple"
};
changeFruit();
}
const Func = () => {
const [fruit, setFruit] = useState("banana");
const changeFruit = () => {
setFruit("apple");
};
changeFruit();
}
Cats萌萌
慕容森
暮色呼如
随时随地看视频慕课网APP
相关分类