javascript React Hooks简单相同

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript React Hooks简单相同相关的知识,希望对你有一定的参考价值。

import React, { useState } from "react";
import logo from "./logo.svg";
import "./App.css";

const App = () => {
  const [count, setCount] = useState(0);
  const [email, setEmail] = useState("");
  const updateEmail = e => {
    const {
      target: { value }
    } = e;
    setEmail(value);
  };

  return (
    <>
      {count}
      <button onClick={() => setCount(count + 1)}> Increment </button>
      <button onClick={() => setCount(count - 1)}> Decrement </button>
      <input placeholder="Email" value={email} onChange={updateEmail} />
    </>
  );
};

export default App;

以上是关于javascript React Hooks简单相同的主要内容,如果未能解决你的问题,请参考以下文章

javascript React Hooks useMemo useCallback

javascript React Hooks setInterval

javascript React hooks에서이전결과값받아올때

函数式编程看React Hooks简单React Hooks实现

React Hooks useCallback 的简单示例的问题

JS周刊#423 - React v16.8 发布:Hooks,对 Vue 来说 Hooks 意味着什么,Vue 2.6 发布