How to update object state with react useState()

To update a state in React is a very simple process using react hooks - useState. Check the code below: Update simple state // import useState hook import React, {useState} from 'react'; //create and export the component export default function MyName(){...

How to run useEffect() only once | React Hooks

Just add an empty array after the callback function separated by a comma useEffect(callback, []); useEffect(()=>{}, []); And if you get any warning for missing dependency, add that inside the array useEffect(()=>{ // your code here }, [dependency_item]); If the...

How to deploy React App to github pages | gh-pages

Make an empty repo on github (no file) Install your react app using this command npx create-react-app yourprojectname Go to your project cd yourprojectname Intall gh-pages npm install gh-pages Add a homepage to package.json...