Giter VIP home page Giter VIP logo

all-about-hooks's Introduction

All-about-Hooks

useState :

  • We call the useState Hook in our component , with the name of the variable and its initial state as an argument :

capture1

  • To change the status of the variable we use the setter function, inside the event click :

Capture2

  • Whatever the value of the variables, it will be assigned to the attributes :

Capture3

useEffect :

  • The first argument passed to useEffect is a function called effect and the second argument is an array of dependencies , When we use this hook , the change of the text button color causes the change of the h1 color :

Capture4

useReducer :

  • The useReducer hook is used for complex state manipulations and state transitions,useReducer is a React hook function that accepts a reducer function, and an initial state :

Capture5

  • useReducer args :

Capture6

  • Calling variables and dispatch :

Capture8

Capture7

useContext :

  • It allows to share data between components, but not only between parents and children, we create the context :

Capture9

  • retrieve the values with useContext :

Capture10

  • Providers: defining the value of context :

Capture11

all-about-hooks's People

Contributors

wijdanechar avatar

Stargazers

 avatar Anas CHAHID avatar BOUCHENTOUF Oussama avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.