1、我使用的react和react版本都是16.7版本。2、我使用的案例是官方react Hooks useState案例。3、相同的代碼,我在我項目中使用webpack等打包工具,但是不生效。4、在https://codesandbox.io/s/j27q... 是可以的。5、代碼如下import React,{ useState } from 'react';function Example(props) { // Declare a new state variable, which we'll call "count"
const [count, setCount] = useState(0); console.log(count,'-----') return ( <div>
<h1 style={{color: 'red', fontSize: 100}}>You clicked {count} times</h1>
<button onClick={() => setCount(count + 1)}>Click me</button>
</div>
);
}export default Example;
1 回答

小唯快跑啊
TA貢獻(xiàn)1863條經(jīng)驗 獲得超2個贊
如果版本號都對的話, 吧node_module 刪除后重新安裝一遍. 還有官網(wǎng)的例子基本不會有問題, 多檢查檢查自己的配置再提問, 可以多貼一點配置代碼這樣大家才能幫你
- 1 回答
- 0 關(guān)注
- 1265 瀏覽
添加回答
舉報
0/150
提交
取消