Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,42 @@
All course files for the Complete React Tutorial on the Net Ninja YouTube channel.

To use, select the correct branch for each Lesson. E.g for lesson 5 code, select the lesson-5 branch from the drop-down.

useEffect Hooks:

useEffect: Run after every render.
e.g.: useEffect(() =>{
console.log('use effect run');
})

useEffect Dependancy: create empty array

e.g.: useEffect(() =>{
console.log('use effect run');
},[]);

then this function run only after initial render and when state changes. here no actual
dependencies in array.

Now add actual dependncies in array:

When name changes automatically render this name. like watch the name

const Home = () => {

const [name, setName] = useState('initial name');

useEffect(() => {
console.log('use effect ran');

}, [name])

return (
<div className="home">

<button onClick={() => setName('updated name')}>change name</button>
</div>
);
}