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贡献1863条经验 获得超2个赞
如果版本号都对的话, 吧node_module 删除后重新安装一遍. 还有官网的例子基本不会有问题, 多检查检查自己的配置再提问, 可以多贴一点配置代码这样大家才能帮你
- 1 回答
- 0 关注
- 1239 浏览
添加回答
举报
0/150
提交
取消