React Hooks强制刷新

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 (
    
); } const rootElement = document.getElementById("root"); ReactDOM.render(, rootElement);
    setTimeout(() => {
      forceUpdate()
    }, 0)

React Hooks强制刷新_第1张图片

参考链接:

https://chat.xutongbao.top/

你可能感兴趣的:(web前端,javascript,前端,react.js)