React useContext() hook introduction 🧗‍♂️

  Рет қаралды 14,717

Bro Code

Bro Code

Күн бұрын

#reactjs #tutorial #course
00:00:00 intro
00:00:13 setup
00:04:39 props
00:06:01 prop drilling
00:06:17 useContext
00:06:27 Provider Component
00:08:28 Consumer Components
00:10:11 multiple consumer components
00:11:10 conclusion
// useContext() = React Hook that allows you to share values
// between multiple levels of components
// without passing props through each level

Пікірлер: 65
@BroCodez
@BroCodez 4 ай бұрын
// useContext() = React Hook that allows you to share values // between multiple levels of components // without passing props through each level // PROVIDER COMPONENT // 1. import {createContext} from 'react'; // 2. export const MyContext = createContext(); // 3. // // // CONSUMER COMPONENTS // 1. import React, { useContext } from 'react'; // import { MyContext } from './ComponentA'; // 2. const value = useContext(MyContext); // ---------- CSS ---------- .box{ border: 3px solid; padding: 25px; } // ---------- App ---------- import ComponentA from './ComponentA.jsx'; import React from 'react'; function App() { return(); } export default App; // ---------- ComponentA ---------- import React, {useState, createContext} from 'react'; import ComponentB from './ComponentB.jsx'; export const UserContext = createContext(); function ComponentA(){ const [user, setUser] = useState("BroCode"); return( ComponentA {`Hello ${user}`} ); } export default ComponentA // ---------- ComponentB ---------- import ComponentC from './ComponentC.jsx'; function ComponentB(){ return( ComponentB ); } export default ComponentB // ---------- ComponentC ---------- import ComponentD from './ComponentD.jsx'; function ComponentC(){ return( ComponentC ); } export default ComponentC // ---------- ComponentD ---------- import React, {useContext} from 'react'; import {UserContext} from './ComponentA.jsx'; function ComponentD(){ const user = useContext(UserContext); return( ComponentD {`Bye ${user}`} ); } export default ComponentD
@jithan977
@jithan977 4 ай бұрын
bro plz upload every day and always thankful for u
@rayyanabdulwajid7681
@rayyanabdulwajid7681 4 ай бұрын
Make a crud todo in vanilla javascript where we can enter more than 1 value inside a form.
@lonelydevilcreations
@lonelydevilcreations 4 ай бұрын
Please make redux and context API videos
@-_SleepAndEat_-
@-_SleepAndEat_- Ай бұрын
Bro can you do Kali Linux ?
@ronjohnson123
@ronjohnson123 2 ай бұрын
What a great explanation! Watched numerous videos before this on useContext & still struggled to understand. I then watch one of your videos & instantly understood! Great work
@reecenward
@reecenward Ай бұрын
yeah same lol
@ChucklesMcGee780
@ChucklesMcGee780 Ай бұрын
thanks for making this. I've been so confused by useContext, after a course and quite a few videos, until i found this.
@JamesTheSuperDev
@JamesTheSuperDev 11 күн бұрын
Short and sweet. Exactly what I have been looking for.
@a13519
@a13519 3 ай бұрын
The best explaination in youtube about context
@remember.772
@remember.772 10 күн бұрын
I subscribed ur channel today cause u deserve it ,u explain with simple terms that's what we need, for juniors first they should understand how it works then they will work with confident
@shreehari2589
@shreehari2589 4 ай бұрын
Yeah no one could have explained it better than you, I hope you will release full react course soon, eagerly waiting for it
@valerylouis6747
@valerylouis6747 4 ай бұрын
Such a simple and easy to understand tutorial. I've watched all the tutorials he has on react, waiting on him to release new ones
@MirzaMesinovic
@MirzaMesinovic 2 ай бұрын
Absolutely amazing tutorial. Impossible to not understand. Thanks!
@java_learn6447
@java_learn6447 4 ай бұрын
Amazing lecture
@hananfadah
@hananfadah 4 ай бұрын
Wow thanks a lot! What a great explanation. Truly appreciate your effort.
@ttsl8922
@ttsl8922 2 ай бұрын
the example is intuitive and easy to understand. ty
@razkoreakpop9805
@razkoreakpop9805 4 ай бұрын
Thank you for uploading video ❤
@shubhamsonar5689
@shubhamsonar5689 4 ай бұрын
love you bro such a super duper easy to understand 🙌
@ilhamnurutomo6930
@ilhamnurutomo6930 Ай бұрын
thanks, great explanation
@topvibe952
@topvibe952 13 күн бұрын
Best Explanation 🤝❤❤
@animatsuki5345
@animatsuki5345 2 ай бұрын
really cool! thanks man! yay
@BishanTamang-rk5ji
@BishanTamang-rk5ji 4 ай бұрын
Make 2024 Java course love from Nepal ♥️💓
@sebastianlozano7707
@sebastianlozano7707 4 ай бұрын
Most of what I know about Javascript is thanks to you! Thanks Bro Code
@bmwmotorbikesdaily
@bmwmotorbikesdaily 2 ай бұрын
Well explained keep it up!
@monmaka
@monmaka 4 ай бұрын
I finally understand it. Thanks bro
@ShashankJ04
@ShashankJ04 4 ай бұрын
Swear to god I have all notifications on KZbin but everytime u upload a new video I get no notification. Love your videos though!! keep on going.
@HarshithramSundararaman
@HarshithramSundararaman 4 ай бұрын
youre videos are great!
@milad8030
@milad8030 2 ай бұрын
I saw different video, but you are better than those. you are not in a rush, explain why we need what. thank you
@THE_UNITED_STATES_OF_AMERICA51
@THE_UNITED_STATES_OF_AMERICA51 4 ай бұрын
You're trying so hard why don't you enable funds in your videos you saves a lot of our money why don't you just benefit a little bit
@available2574
@available2574 4 ай бұрын
Bro you are hero...
@valerylouis6747
@valerylouis6747 4 ай бұрын
I'm bout to watch this tutorial today. Anything from bro code, I know it's good
@abhishekjaiswar5182
@abhishekjaiswar5182 Ай бұрын
Finally I got it...❤
@pastori2672
@pastori2672 4 ай бұрын
i swear everytime im concerned about a concept you make a video about it
@pratyushkiran8654
@pratyushkiran8654 4 ай бұрын
Uff ! That was easy 🔥🔥
@razkoreakpop9805
@razkoreakpop9805 4 ай бұрын
Your the best
@Blade_Dhruv
@Blade_Dhruv 4 ай бұрын
you can use eslint react extension for typing react code faster
@user-ur3io2ny2j
@user-ur3io2ny2j 2 ай бұрын
Please continue teaching react.. upload new video you are expert in this💔
@satisfying_shapes
@satisfying_shapes 4 ай бұрын
thanks for explanation, but does needs to have 'user={user}' for useContext to work?
@BroCodez
@BroCodez 4 ай бұрын
You can remove user={user}, I forgot to do that in the demo
@satisfying_shapes
@satisfying_shapes 4 ай бұрын
@@BroCodez thank you for letting me know ❤❤
@togya4
@togya4 4 ай бұрын
I wish u talked about it earlier cuz 6 months ago i was so lost ):
@KingOfMadnesss
@KingOfMadnesss 4 ай бұрын
Day 1 of asking for an sfml full course (after your done with this course)
@ahmadyakubuahmad7626
@ahmadyakubuahmad7626 4 ай бұрын
Bro we want to see your face and say Thank you!
@shreehari2589
@shreehari2589 4 ай бұрын
You can see him on twitch
@smithclash2898
@smithclash2898 4 ай бұрын
​​@@shreehari2589what's his twitch Id?
@nebojsaknezevic6053
@nebojsaknezevic6053 16 күн бұрын
Can it work in reverse? Make component C provider and then have componentA consumer?
@rishabhkedia9304
@rishabhkedia9304 4 ай бұрын
Please make Reactjs projects as well
@DeadEnd_579
@DeadEnd_579 4 ай бұрын
Hey can u continue Data Structures and Algorithms Playlist on
@arshadahamed988
@arshadahamed988 27 күн бұрын
Can we have more values in single usecontext hook??
@sunilmehta5237
@sunilmehta5237 3 ай бұрын
but how does a UserContext know that it has to provide a User data, is it by naming ? Please can someone answer this ? The reason I am asking by your example is what if I want to create this context a standalone JS class.
@RhemaOshogwe
@RhemaOshogwe 4 ай бұрын
Please I need help, I'm using php(xampp) I can't find the php.exe, I've deleted and reinstalled many times I still can't find it, I just need to know if I can use PHP in vscode without it?
@RhemaOshogwe
@RhemaOshogwe 4 ай бұрын
The same error it showed on your vscode when starting PHP that's what it's still showing in my own, but I cant find the php.exe
@nesa6582
@nesa6582 4 күн бұрын
Naming variable UserContext was super confusing. :D
@Nova_Software
@Nova_Software 4 ай бұрын
Day 1 of asking for a typescript tutorial, a c# with xaml tutorial and a Pygame tutorial
@lonelydevilcreations
@lonelydevilcreations 4 ай бұрын
Please create redux and context API tutorial
@raitaskeen
@raitaskeen 4 ай бұрын
Bro can u make a lecture on RUST...!
@hashirowais6475
@hashirowais6475 4 ай бұрын
how many videos are left till this series is over?
@BroCodez
@BroCodez 4 ай бұрын
Why, do you not like it?
@hashirowais6475
@hashirowais6475 4 ай бұрын
@@BroCodez No I love it. I just want to know much is left before I can start using react to create my own applications :)
@santoshchulakimath
@santoshchulakimath 2 ай бұрын
6:39 for my reference p1-p2
@ish7862
@ish7862 4 ай бұрын
🫡🫡🫡
@capslock3250
@capslock3250 18 күн бұрын
Personally, I find useContext to be the most confusing hook.
React useRef() hook introduction 🗳️
11:18
Bro Code
Рет қаралды 10 М.
Context API in react | get the concept
29:00
Hitesh Choudhary
Рет қаралды 39 М.
Super sport🤯
00:15
Lexa_Merin
Рет қаралды 20 МЛН
Would you like a delicious big mooncake? #shorts#Mooncake #China #Chinesefood
00:30
React useEffect() hook introduction 🌟
19:52
Bro Code
Рет қаралды 14 М.
All useEffect Mistakes Every Junior React Developer Makes
22:23
Build a DIGITAL CLOCK using React in 15 minutes! 🕒
16:00
Bro Code
Рет қаралды 13 М.
React useState() hook introduction 🎣
16:33
Bro Code
Рет қаралды 16 М.
Build this React To-Do List app in 20 minutes! ☝
22:35
Bro Code
Рет қаралды 29 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 373 М.
ALL React Hooks Explained in 12 Minutes
12:21
Code Bootcamp
Рет қаралды 64 М.
Super sport🤯
00:15
Lexa_Merin
Рет қаралды 20 МЛН