install react hooks code example

Example 1: react hooks

const [state, setState] = useState(initialState);

Example 2: react hook install

npm i -S [email protected] [email protected]

Example 3: react hooks

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>
  );
}

Example 4: react hooks npm install

npm install @apollo/react-hooks