Test the new react feature hooks, which does not take effect.

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;
Apr.17,2022

has react-dom been updated


if the version numbers are all correct, delete node_module and reinstall it. There is basically no problem with the example on the official website. Check your configuration more and then ask questions. You can post more configuration codes so that everyone can help you


you need to install the v16.7.0-alpha.2 version to support useState


. Is it solved? Could you let me know

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea914b-1f29.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea914b-1f29.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?