React Hooks

What is HR Automation?

It is a feature introduced to play with states in functional components as previously it was just being used with class components only. Hooks are the functions which “hook into” React state and life cycle features from function components. RULES FOR USING HOOKS: (1)- Only call hooks at top level (2)- Only call hooks from react function SYNTAX INVOLVED WITH USING STATE IN HOOKS:

 

import React, {useState} from ‘React;

  1. importReact, { useState } from ‘react’;  
  2.  
  3. function CountApp() {  
  4. // Declare a new state variable, which we’ll call “count”  
  5. const [count, setCount] = useState(0);  
  6.  
  7. return (  
  8. <div>  
  9. <p>You clicked {count} times</p>  
  10. <button onClick={() => setCount(count + 1)}>  
  11. Click me  
  12. </button>  
  13. </div>  
  14. );  
  15. }  
  16. export defaultCountApp;

BASIC HOOKS:

(1)- useState()

(2)- useEffect()

(3)- useContext()

Sana Eram

Data Scientist Intern

Register a Free Cloud ROI Assesment Workshop

Register a Free Cloud ROI Assesment Workshop

Get a Detailed assessment report with recommendations with an assessment report

Schedule free Workshop
Register a Free Cloud ROI Assesment Workshop
Register a Free Cloud ROI Assesment Workshop

Related articles you may would like to read

Leveraging Data Management Maturity Model to boost data management capabilities

Request a Consultation