react hook list code example

Example 1: reference hook in react

import React, {useRef} from 'react'
const displayNode = useRef(null)
//action
displayNode.current.textContent = `${count} Appointments Successfully Uploaded`
//referenced object
<div ref={displayNode} className="text-center mt-3 msg" style={{ color: "green", fontWeight: "800" }}></div>

Example 2: 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 3: react hooks

componentDidUpdate(prevProps, prevState) {
  if (prevState.count !== this.state.count) {
    document.title = `You clicked ${this.state.count} times`;
  }
}