1. The react and react versions I use are both version 16.7.
2. The case I use is the official react Hooks useState case.
3, the same code, I use packaging tools such as webpack in my project, but it doesn"t work.
4. It is OK in https://codesandbox.io/s/j27q....
5. The code is as follows
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;