import React, { useReducer } from "react";
import ReactDOM from "react-dom";

import "./styles.css";

function App() {
  const [, forceUpdate] = useReducer(x => x + 1, 0);

  console.log("Rendered! or did I just re-render?");

  return (
    <div className="App">
      <button onClick={forceUpdate}>Force Update</button>
    </div>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
setTimeout(() => {
      forceUpdate()
    }, 0)

React Hooks强制刷新_css