xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

React Hooks: useState All In One

useState

import React, { useState } from 'react';

function Example() {
  // Declare a new state variable, which we'll call "count"
  const [count, setCount] = useState(0);

  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>
        Click me
      </button>
    </div>
  );
}

https://reactjs.org/docs/hooks-reference.html#usestate

https://reactjs.org/docs/hooks-overview.html#state-hook

https://reactjs.org/docs/hooks-state.html




refs



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


原文地址:https://www.cnblogs.com/xgqfrms/p/13901744.html