Skip to content

Latest commit

 

History

History
65 lines (40 loc) · 1.34 KB

README.md

File metadata and controls

65 lines (40 loc) · 1.34 KB

USESTATE

General Rules of Hooks

Component name must be Upper Case USESTATE cannot be outside of the function or Components body cannot call conditionally

eg : if () { hook is inside here = useState } Result will be Error.

We can use multiple useState values.

useEffect

By default runs after every re-render Cleanup Function Second Parameter

We cannot call Hook comditionally second condition or second parameter is []array of dependencies or list of dependencies
Each time its dependencies [] will change and re-run. You can use as many useEffect as you want but if you left the dependency array [] empty , it will run only one time

Eg: useEffect(() => { console.log('Hello World');

}, []) // In this case , Hello World will be printed only one time, since empty dependency . 
  • Everytime, we have useEffect , we have the optional return.

Forms

  • In Js 👾 const input = document.getElementById ('mytext'); const inputValue = input.value

  • In React 👾 value , onChange

UseRef

  • preserve values
  • Does not trigger re-render
  • target DOM nodes/elements

UseReducer

  • better usecase for the big projects

Content API

React Router Dom and Router Link --> npm install reaact-router-dom

useCallback