IMPORTANT TAKE AWAY FROM VIDEO The on click method in React expects a function reference You can't directly pass parameters inside the function, instead, you need to pass it as a reference or use arrow function syntax 17:12 Refresh karne pe olive is lie aa rah a kio ke usestate ki defualt value di ha humne
@curiousforever12719 ай бұрын
please check the video once again from 14:36, Onclick expect the function not function reference or function return value. And also last 2 line of yours is correct
@sahilmane26018 ай бұрын
@@curiousforever1271 He is talking right bro. when you want to pass anything in onClick function, you have to pass the function reference that's why if you want to pass any function without parameters, for example handleClick() you will write like this, onClick={handleClick}. It is without parantheses because it is reference for that function and passed as an onclick event handler. Ofcourse you can like it like this onClick={()=> handleClick()}. But we mostly write this syntax when you have any parameters in the function. I mean to say that this person commented is right that it passes function references. Research on your own.
@Azharuddin-khan6 ай бұрын
@@curiousforever1271 Yes that's correct, also he said "The on click method in React expects a function reference" but this is not about react. This is will happen in plain javascript and html as well. it has to do with javascript not react
@Devharsh007 Жыл бұрын
8:48 Note: Of your background Color doesn’t change, delete all the initial styling from index.css (don’t nt remove tailwind’s 3 lines of code)
@umardarazofficials3529 Жыл бұрын
saved me
@IFYatharthAurangpureIT Жыл бұрын
Thanks bro❤
@shreyanshkumar4528 Жыл бұрын
thanks
@community4u Жыл бұрын
thanks man ❤🫂
@aaryanbhardwaj9739 Жыл бұрын
not working don't know why it is not taking the width height as that of the page
@ankan-dev Жыл бұрын
Actually the initial state has color olive and the reload technically resets the state. So, it gets the olive color.
@Sandeep_04512 Жыл бұрын
I think this is right
@rdrenio Жыл бұрын
apna default color olive hai that's why after clicking refresh its show olive color
@guptasagar69411 ай бұрын
Obviously
@abhishektrivedi137710 ай бұрын
Same answer. ;)
@RayanTanzeem10 ай бұрын
agar latest color ko local storage mein save kr lein tou desired output aye gi
@sehajdeepsingh74278 ай бұрын
1:39 Paused and completed the task. My approach was a bit different, I created a component and passed required color in the props, which created a button with {props.color} text and executed onclick btn which passes to function colorChange where the props.color is set { document.body.style.bgColor = props.color; } Thus it only took me 10-11 line of code and 7 component line code for 7 different colours.
@RRR-yz1kfКүн бұрын
i also did with the same approach🤭
@anshuldigan5859 Жыл бұрын
literally this channel will become the best code channel on youtube one day
@GenZdev Жыл бұрын
Channel hi banna hai. Sir hamare already no 1 hai 😎
@navinkumarsahu1159 Жыл бұрын
definitely bro but that'll happen only after you share this channel
@chaiaurcode Жыл бұрын
❤️❤️❤️
@bgspradeep Жыл бұрын
@@chaiaurcodenext project todo app le aao sir
@abhipatil7 Жыл бұрын
It's already the best. But underrated.😅
@JatinBisht Жыл бұрын
Completed 9 videos loving it to be very honest its sometimes complicated to learn from english video but this playlist directly connects with the heart and mind or hum chai peene ke sath react ke concepts bhi nhi bhool paate. Thank you sir hitesh sir >>> college
@anuragbhattacharjee39849 ай бұрын
17:20 because default value of color was set to olive in the useState.
@Debraj-HTC Жыл бұрын
The initial value in the setState is olive, that's why background defaults to olive upon reloading.
@deepeshji Жыл бұрын
page refresh, it took default useState value which is "olive".
@farmanali6349.channel10 ай бұрын
17:12 Refresh krne par dobara se DOM print hota hai, ham by default jo color state ka value dia hua hai wo olive hai, is liay refresh krne pr olive aa raha hai.
@vivekhalder2974 Жыл бұрын
Sir, the initial state is set once a page is reloaded. Sir, I also understood why two curly braces were used in style part. coz one to show that it is a js statement + the second one for the object. style is an object. last class mein aapne sikhaya tha ki code reusability ke liye ek component ko baar baar reuse kiya ja sakta hai. Yaha meine button ka component banate reuse kiya use. Button.jsx import React from "react" function colName(color){ return color.charAt(0).toUpperCase() + color.slice(1); } function Button(props){ const buttonStyle = { backgroundColor: props.color, color: props.text || "white" } return ( {colName(props.color)} ); }; export default Button App.jsx import { useState } from "react" import Button from "./components/Button" function App() { const [color, setColor] = useState("olive"); const handleButtonClick = (color) => { setColor(color); } return ( handleButtonClick("red")}/> handleButtonClick("green")}/> handleButtonClick("olive")}/> handleButtonClick("grey")}/> handleButtonClick("yellow")}/> handleButtonClick("pink")}/> handleButtonClick("purple")}/> handleButtonClick("lavender")}/> handleButtonClick("blue")}/> handleButtonClick("white")}/> handleButtonClick("black")}/> ) } export default App;
@adityatomar3784 Жыл бұрын
@17:15 initialSate is Olive Thank You Hitesh Sir for the Superb content
@ajtechclub Жыл бұрын
17:15 as olive is the default value for variable color and on clicking button we are updating values & UI as well
@abhisheksubhashram6910 Жыл бұрын
Refresh karte hi color ko value olive set horahi hai that is useState ki default value: useState("olive") . Thankyou so much sir for this beautiful lecture
@alakhkaler664 Жыл бұрын
Your content really awesome no-one can replace you, Sir please try to upload videos regularly but the only problem is consistency
@MohammedHasmi5778 ай бұрын
Sir i have made this project by myself without watching this video , literally cry after seeing my progress i dont have any words for you jajakallah so much sir ❤❤❤
@LearnWithManan.1108 ай бұрын
nice brother keep learning Allah pak kaamiyab kare ga apko, mene bhi banaya ye mene sirf ak component banaya bs button ka or phir import kar liya thora logic laga magar ho gaya props ke bhi use kiya mene❣❣
@pranavanand24 Жыл бұрын
Very nice video again and because I paused the video right at the start and attempted it by myself so I ended up making different components for container and buttons. Because I took this approach, I also came across this irritating problem where button text was getting lost becasue of background color, so I used ternary operators to sort that out and use "white" for black button. I noticed that you too have done that in your original finished version which you didn't discuss in the video and that was great! Learnt a lot again
@KapilMaan-vw9sd6 ай бұрын
u are right i use text-white for black color
@Academics_Srijan2 ай бұрын
useState me initial state Olive colour hai that is why wo refresh karne kar initial value le leta hai by default which is olive colour!!!... Thank you so much for the in-depth series Sir! ❤
@dineshshinde2116Ай бұрын
14:46 If we call to the setColor it is the method and we can't give the argument so that we could able to update it so for that purpose., we are firing a call back to avoid that 17:22 As "olive" color is set initially and gave refrence of that in inline css so that it is triggering Grasp things - 1. React - inline css : - when ever we want to give the inline css at that time we cant to write the two curly braces and then in that the css properties as . The property should be separated by the comma , style={ {backgroundColor: color, height:"200px"}} 2. if we are enjecting any variable instance so we are not required to enclose it with the curly braces as that is already in the curly braces - style={ {backgroundColor: color} }
@suryaallinone2931 Жыл бұрын
17:18 Because, first me background color : olive set kiya hai
@SikhleTu11 ай бұрын
17:20 sir ne toh dra hi diya😂😂.. puch rhe ya dhamka rhe❤❤
@Nagar20244 ай бұрын
You’ve got me falling in love with React all over again! ❤💻, Thank youuuuuuuuuuuuuuuuuuu so much Sirrrrrrrrrrrrrrrrrrr!
@asifsaeed77164 ай бұрын
ap k samjhany c to itna smj a e gia h k olive color es liyee a rhaa we set olive color in initial state. when we reload then reset the state and color olive e aaay ga na .. thanks for learning us with good n friendly style sir .. more respect from Pakistan
@MelbinKurien14 күн бұрын
Refresh krne pe wapis vo olive islie ho rha hai kyunki jaha humne state define kia hai waha color ka default value olive hai agr use black krdenge toh vo black hojayega refresh krne pe ya koi bhi color jo hum default mai dede .
@SagarBisht-ww4tm6 ай бұрын
specificity in css , inline style has been given highest priority , it is default color so it is olive
@AshwaniSingh-b7d4 күн бұрын
17:15 Because you have set default color as olive so that's why when we refresh the page the color become olive
@adnanjamil2956 Жыл бұрын
what a teaching style sir 💌💌 love from pakistan 💌💌
@swapnildapkosh28134 ай бұрын
initially we have set the state to "olive" color that's why on refresh it is turning to that color. Awesome explanation 👍. Thanks Sir.
@codingbyte8476 ай бұрын
onclick method in react expects a function, so here we have to pass function not a parameter. Thanks a lot sir for this great series🥰🥰🥰
@LearnWithManan.1108 ай бұрын
Sir mene to ak hi button ka component banaya or kaam ho gaya♥ Code: let text = props.text; return ( { document.querySelector("body").style.backgroundColor = text; }} className="px-10 py-3 rounded-full text-white border-none" style={{ backgroundColor: text }} > {text}
@manglam65554 ай бұрын
React's useState doesn't persist state across page reloads. When the page refreshes, the entire component re-renders, and useState resets the state to the initial value defined in its argument
@arghya_08029 ай бұрын
17:12 The intial value of color is set as "olive" which we are using to set the backgroundColor of our parent div, that's why on refreshing we are getting olive in place of any other color
@amitaeyron7585 Жыл бұрын
I have completed this project as a task. And enjoying development with chai aur react . Thankyou so much for guiding us .
@avanishexplorer Жыл бұрын
🤩 easypezy project with fun.... Just addicted to this playlist
@SHUBHAMJHA-o3g5 ай бұрын
the image at 16:58 is good overview of the code. Its the css part. otherwise the hook is the important one.
@zrotrasukha87338 ай бұрын
17:13 ye isliye hua kyunki aapne useState me default value "'Olive" kar rakha hai. I can't thank you enough for this course sir.
@gaurabsingh931729 күн бұрын
whenever we refresh the page the react components re-renders and the state is set to initial value(olive) . React state is ephemeral (it is lost on page refresh because it exists only in memory).
@nandishbt240519 күн бұрын
Actually the initial state has color olive and the reload technically resets the state.
@vinay_dev195 ай бұрын
when we reload the page the background is return to the default color bacause the change we do in page is not save anywhere , and when we reload the page browser dom is repainting. in other word actually the initial state has color olive and the reload technically resets the state. So, it gets the olive color.
@RahulKumar-tz5ic5 ай бұрын
you make easy to understand sir 🤗 I was worried that how can I learn these code because it was like rocket science in your language 😅 btw, thank you sir.
@mukesh3055 Жыл бұрын
Hitesh sir your teaching method is unique from others
@rushidave7092 Жыл бұрын
17:15 because olive is default variable color define in useState.
@akshayramani62639 ай бұрын
The default color olive is set in the usestate, so when the state is reloaded the state resets and the color changes.
@aashutosh9375 ай бұрын
Because the initial state for color is set to olive so when the page reloads it goes back to default color which is olive
@sohomdas27674 ай бұрын
17:20 default value olive, so when reloading the webpage, it (useState) changes the value to the default value i.e. olive
@ravindrasaini67896 ай бұрын
Actually the initial state has color olive and the reload technically resets the state. So, it gets the olive color.
@aakashsaini94724 ай бұрын
the initial state has color olive and the reload technically resets the state. it gets the olive color.
@Archit-Mishr14 сағат бұрын
17:20 because default value of state is set to Olive.
@thecalgarians45978 ай бұрын
Loved this simple yet powerful project❤
@themonkspeaks2996 ай бұрын
defualt value set is olive that's why it is showing the olive color when refreshed
@mycollegeLife. Жыл бұрын
cuz initial state olive h to reload hone pe dom repaint ho jata h aur bg color olive set ho jata h.
@prateekshrivastava280211 ай бұрын
As useState has Olive color initialized to it !! Amazing video sir ,Thankyou !!
@sameershahidbuttaАй бұрын
17:23 page refresh krnay pr useState wali initialize value yaani "olive" ko lga deta hy
@vishalbelwal34458 ай бұрын
Thanks a lot sir video pause karke jitna ab tak sikha tha aapse wo sab use karke khud se banaya hai pura project ye wala i know basic hai sir ye project but still thankyou aapka padhane ka traika hi khuch aisa hai ki koi cheez bhooli hi nahi jati 🙏🙏
@priyankasaini7204 Жыл бұрын
6:18 "agar m likh paaya to"😂bahut hasate hasate padhate ho ..maja aata h apse padhne m
@pritimodanwal06 Жыл бұрын
initially state value is olive that's why whenever page is reload initial state value is changing and define default whatever we are defining in useState('olive');
@bibhudendupalai5234 Жыл бұрын
nice project Basic building Refresh ke bad pura dom reload hota hai na wo usestate ka defult value leta hai
@Zed.h-y9m7 ай бұрын
Olive islie .. qk state ki initial value ham ne olive set kr rakhi hai.. so whenever we refresh the page state b apni initial value pe chala jaata hai...
@nehakaler66777 ай бұрын
Finished this video. Loving the series. Thankyou Sir.
@NoTimetoexplaiNnАй бұрын
Olive is the default value of the color set by the user so when you refresh the page reloads and the value of color is olive so the bg is olive
@v1shal_yadav11 ай бұрын
as olive is the default value for variable color and on clicking button we are updating values & UI as well
@AjayKumarShahu-i6r5 ай бұрын
The default background color is set to olive when the page is refreshed. This is achieved using the useState hook in React, which initializes the background color state with the value 'olive' on the initial render.
@r4ge8489 ай бұрын
he initial state has color olive and the reload technically resets the state. So, it gets the olive color.
@punitkingvlogs27 күн бұрын
because usestate set is olive color so after refreshing page the set is useState color
@flash81358 ай бұрын
Becuase you already had initialized the color state with the olive color and whenever you refresh the browser it renders the component or reset the state variables
@deepakfauzdar80348 ай бұрын
olive is the default value, once page gets reload, the state again sets to olive as it is the default state.
@gurusacademy2021 Жыл бұрын
I did it using components (code is below). Awesome Explaination. return ( handleEvent("red")} /> handleEvent("green")} /> handleEvent("blue")} /> handleEvent("yellow")} /> handleEvent("pink")} /> handleEvent("violet")} /> handleEvent("white")} /> handleEvent("black")} /> )
@komalverma91045 ай бұрын
17:13 after reload color apne initial state me wapis aa jata h.. That's why after reloading we get olive color
@addysin0042 ай бұрын
beacuase the default color is set to olive. to change this we can save the value of color to local storage so that even after reloading the value of color remains what it was before reload
@abhijithjana2001 Жыл бұрын
Acutely the initial value of colour is olive . As restart the page program will start it's execution from root (line number 1)
@ajeetkumarrauniyar7 ай бұрын
17:21 default value is olive which is rendered after the page refresh.
@r4ge8489 ай бұрын
IMPORTANT TAKE AWAY FROM VIDEO The on click method in React expects a function reference You can't directly pass parameters inside the function, instead, you need to pass it as a reference or use arrow function syntax 17:12 Refresh karne pe olive is lie aa rah a kio ke usestate ki defualt value di ha humne
@MohammedHasmi5778 ай бұрын
17:18 refresh krne pr olive kyu ho rahaa hai? Sir ji hamne initial state me color olive use kiya hai so refresh krne pr initial state me aayega jiska color olive hai ❤️❤️
@ApurvaKalvadeSDE11 ай бұрын
There is also an optimization technique for writing the onClick methods. Event Delegation if I am not wrong. Write a common onClick method on parent and refer each child with name .... and the parent tracks the element's name in "e.target" ... from there also, we can set the value of bg-color. This is bcoz we are adding handler to each buttons. If there are 100s of color buttons then 100s of handlers will be created for each buttons which is not good for page performance.
@vivekmishra439811 ай бұрын
can you share this in code
@rjl681410 ай бұрын
17:15 useState me olive set kr ke rhke hue h . olive ke jhga blank rhe gy to by default white lelega
@zayyynull_ Жыл бұрын
That was a great tutorial. Thanks man!!!
@sourajkhatua20003 ай бұрын
Because The Default Color Has Been Set To olive .. And By The way love Your Content Hitesh Sir.. Do such Video more....♥♥♥♥♥♥
@grover2411 ай бұрын
olive is the default state . when we reload the page none of the values (i.e. red, green, blue) is selected so browser loads the default color that is set by us in the very beginning
@itsnazirali10103 ай бұрын
initial state of the background color is olive , so when you hit refresh or Rerender the state the in initial state is display it
@Suraj_Hasule6 ай бұрын
bcoz initial state value (color) olive and after reload resets all state ,that's why color is olive
@SenseiVraj6 ай бұрын
17:26 because we set the color at olive hard coded so... when we reload it sets the color to default which is olive
The initial value of the useState('olive') is applied after reloading. The initial value is being used.
@Powerful-Manifestor-5 ай бұрын
Refresh karne pe app reload hoti hai to component phirse create hoga and color ki initial value olive set kar dega
@ankitpatel88185 ай бұрын
the color change because when the page reload the color change to its initial state which is Olive
@yugkrishnagaming53786 ай бұрын
sir `setColor` on default "olive pe set h isliye har bar reload krne p vo bg olive hota h. we can use localStorage to prevent it.
@visheshgupta49904 ай бұрын
Because the initial state we set is olive colour and when we reload the page it resets it to the initial state which is olive colour that is why on reloading the page olive colour is displayed .
@jeeveshkumar96824 ай бұрын
This project is a good chance to show off your knowledge via Event Delegation concept. Instead of adding event listener to each button you can put it on parent div.
@jeeveshkumar96824 ай бұрын
Background Changer Red blue green
@Ghoul-jy4ec7 ай бұрын
On refresh it's olive cause we have defined the olive color at the initialisation of the color in the useState.
@soumalyachakraborty5747 ай бұрын
Actually the initial state i.e. in useState('olive') is set so that's why on refresh its showing its default color set in useState('olive')
@ankushmaurya942611 ай бұрын
Because we have given the constant value in the useState as Olive that's why it is changing to olive after refreshing which resets the state.
@shivanshsaxena93368 ай бұрын
Olive is the default color in usestate therefore when we refresh our webpage it automatically changes its bg-color to olive
@vishwakarma-gaurav6 ай бұрын
olive color is coming on refresh, because the preset value in the useState function if set to be "olive"
@gaurijadhav95017 ай бұрын
Thank you so much sir. for giving confidence ..Created react first program
@PCuser-o3y5 ай бұрын
17:24 because we have set the default colour to be olive when declaring the useState() in the function
@Akbarali00118 ай бұрын
Because we have set olive as default background color but when we click specific colored button the our setColor takes argument value which we have passed and change the color parameter value
@hariomchouhan25205 ай бұрын
Because olive is default value of state and the reload state is take a default value. so it gets the olive color
@ToLoHasso7 ай бұрын
Refresh karne se pura page paint naya dom tree ban rha hai, toh nae dom tree mai jo value initialise ki hai vo he jaegi islie page olive he paint hoga refresh karne pe 17:26
@sameer07x1929 күн бұрын
This video is 80% tailwind 20% logic
@Ovi_93 Жыл бұрын
Becoz you had set the initial state of useState to 'olive' like in counter app we set it to 0, so thats why it is reseting its state to initial