Props from Child to Parent Component (Hack)

  Рет қаралды 121,634

Code with Ania Kubów

Code with Ania Kubów

Күн бұрын

Hello Everyone!
In this video, I show you a hack on how to pass props from your Child Component, to you parent component using React Hooks.
If you did like this video, please hit the Like and Subscribe button so I know to make more!
Twitter: / ania_kubow
KZbin: / aniakubow
Instagram: / aniakubow
#react #reacthooks

Пікірлер: 292
@simba4572
@simba4572 3 жыл бұрын
thank you I was about to literally disintegrate
@aniakubow
@aniakubow 3 жыл бұрын
Hahaha no problem 😍
@marksimpson4310
@marksimpson4310 3 жыл бұрын
I've watched a fair few programming tutorials. What's great about this is: Simple example to help us grasp the concept. Not too much technical jargon, so great for beginners like me. Concise. The video is only eight minutes long.
@plumplumi
@plumplumi Жыл бұрын
thank you so much ! especially at the end where you explain which part is related to which in the code. That's the part I find most lacking in lots of coding videos.
@christophelosiewicz5873
@christophelosiewicz5873 8 ай бұрын
Thanks a lot ! After viewing 50 videos, you are the only one who gives an answer simple ! (sorry for m'y english)
@jomascarbProc
@jomascarbProc 2 жыл бұрын
you just saved my life with this video. I've been stuck in this problem for many hours
@thomasadelaney5479
@thomasadelaney5479 3 жыл бұрын
Well done, Ania! Struggling to find EASY way to programatically pass props back to parent w/o user interaction. Your example gets me started. THX!
@CanisLupusBG
@CanisLupusBG 3 жыл бұрын
You rock. Now. In the year 2023 you will rule 'em all. Kudos, Ania.
@biovawan
@biovawan 3 жыл бұрын
Thank you! You can shorten the line 12 to "". Just passing the func's ref
@Gallersatz
@Gallersatz 2 жыл бұрын
I thought this too, but for some reason my project simply would not work unless I specifically typed word => like she did. Not sure of the reasoning, but on my project, Pretter put word into () and my Dracula theme formatted the font to look like props despite no props being declared (in Dracula, props turn into orange italics). I'd be interested to know why it works for some projects and not others.
@francescociulla
@francescociulla 3 жыл бұрын
0:14 😂. Great video !
@aniakubow
@aniakubow 3 жыл бұрын
hahaahahahaha! I had fun with that one
@JamesQQuick
@JamesQQuick 3 жыл бұрын
@@aniakubow hahahah I laughed there too!
@puruvijay6185
@puruvijay6185 3 жыл бұрын
Same 🤣🤣
@utkarsh_katiyar
@utkarsh_katiyar 2 жыл бұрын
Finally after so many videos on this topic, I finally found the one. Thanks
@unitybr3222
@unitybr3222 2 жыл бұрын
Kisses from Brazil, you saved my world!
@jotasenator
@jotasenator Жыл бұрын
OMG, I pressed so hard the subscribe button after watching the video that I sent props to the parent myself. Nice ❤
@w1pe0ut
@w1pe0ut 3 жыл бұрын
For all those young hackers out there. You can just put a setFunction of useState hook inside prop , call it in child component and it will affect value in a parent component. (:
@BoBoO22595
@BoBoO22595 3 жыл бұрын
Genius! thanks!
@Romeo-vt8hq
@Romeo-vt8hq 3 жыл бұрын
your way doesn't work it throws an error : TypeError: prevDeps.join is not a function
@Zaveram
@Zaveram Жыл бұрын
I was researchig about it, but I was understand. I watched this video, now my component works. Thank you so much!
@avdheshyadav9796
@avdheshyadav9796 2 жыл бұрын
loved it. have been searching 2 hrs and finally got something staright to thte point
@Aaron-sy5yx
@Aaron-sy5yx 2 жыл бұрын
Love this one. Was able to implement in a project and saved the day
@triedtested3236
@triedtested3236 2 жыл бұрын
Hey Aaron was this a personal project or work project? 😊
@gopinathkrm58
@gopinathkrm58 3 жыл бұрын
The British accent + Teaching style is amazing
@Tesudzi
@Tesudzi 3 жыл бұрын
so true mate, and her big blue-grey eyes with that blond looks fantastic. So happy to find her.
@arashkhaan4930
@arashkhaan4930 2 жыл бұрын
i can't stop looking at her face when im trying to just underestand the concept, she's goddamn look amazing
@BlockCylinder
@BlockCylinder Жыл бұрын
I've done this in the past, and I just did it again today. I have a reusable "Search" component which is an MUI text input with autocomplete. It takes the array of options and the label/placeholder string as props, and I want to pass the user-selected option back to the parent. I don't know if it's a hack, but it works well and it means I don't need to implement any global state management. It's also nearly identical to Angular @Output decorators which use event emitters to send data up from child to parent component.
@VeredaProductions
@VeredaProductions 2 жыл бұрын
Thank you soooooooo much for the leson. You've solved all my problems with a magic trick. I'm still studying it to figure out how it is actually happening...
@nicolaszambrano6076
@nicolaszambrano6076 3 жыл бұрын
You saved me, I'm doing a technical test for a company and i solve my problem with this, Thank U !!!!
@pascal5238
@pascal5238 3 жыл бұрын
Thank you so much for this video -- it helped me solve a problem for which I've spent hours trying without success, until I saw this :D
@NewWorldGamingg
@NewWorldGamingg 7 ай бұрын
so u basically pass setstate function as a prop from parent to child and with the help of this setState function u can make changes to the parent function
@dollarmatian
@dollarmatian 3 жыл бұрын
🙏🏽I LOOOOOOOVE hearing yuuuu say PASS... Aurally Magical! ✨
@aniakubow
@aniakubow 3 жыл бұрын
Thank you for watching 🤩
@gofigure1624
@gofigure1624 3 жыл бұрын
Dope! Very useful. Just used this in an assignment in Bootcamp I’m attending thanks again.
@szhzs6121
@szhzs6121 2 жыл бұрын
you could also define the button in the parent and pass it down to the child. that's a better pattern in more complex scenarios, as it avoids passing props through multiple levels of child components (so called prop drilling). // Parent const changeTitleToMyName = setWord(process.env.REACT_APP_DEVELOPER_NAME) const button = return { ... {button} }
@zym0tic428
@zym0tic428 Жыл бұрын
Thanks for this video! I was stuck for a few days pulling my hair out and this really helped!
@anakinstone619
@anakinstone619 2 жыл бұрын
Thank you! i'm learning React and i was trying to get something like emit from Vue to pass data to parent
@musiclovers8488
@musiclovers8488 3 жыл бұрын
Thanks dear!! God bless you… And You bless us with your coding skills 🥰🥰… And one more thing you have really beautiful smile …. So keep smiling
@hollyho6003
@hollyho6003 3 жыл бұрын
This helped me understand props better! Thank you so much again for a great video
@marcnadal8361
@marcnadal8361 2 жыл бұрын
Thank you so much, I almost changed the whole design of the page if I didn't saw this. You saved my life and time. ☺️
@sunnyy6295
@sunnyy6295 2 жыл бұрын
About to use redux reducer selector etc. This helped me from all these.
@cintron3d
@cintron3d 3 жыл бұрын
Nice tutorial! I Wouldn't really call this a hack - it's just how it's done. What you've shown here is actually much better than mutating the dom or a global variable which are what I'd consider to be hacks. By the way, arrow functions inside a render mean that your function will get re-created every render - which isn't optimal. For small apps it'll probably never have an impact on performance but still it's better practice to declare your functions as const outside of the render. Keep up the good work! I'm so glad you're here creating content that my sister and perhaps future daughters can look up to and learn from. 👍
@npaul1440
@npaul1440 2 жыл бұрын
agreed. Waste of tine.. But good for those who still haven't thought of it.
@arman3400
@arman3400 2 жыл бұрын
Thank you for this, this was the video that helped me connect the dots. Subscribing now.
@Sobieski526
@Sobieski526 3 жыл бұрын
Thanks Ania! Super helpful to learn how to lift the state and pass between components
2 жыл бұрын
Thanks Ania, I solved a problem. Greetings from Argentina.
@aksxmtvnty9
@aksxmtvnty9 3 жыл бұрын
"Cool", haha enjoyed this super simple hack, thanks alot.
@aniakubow
@aniakubow 3 жыл бұрын
Thanks so much for watching!
@aksxmtvnty9
@aksxmtvnty9 3 жыл бұрын
@@aniakubow I have just finished the 2048 game, your tutorial helped me alot. Let me host the game and share it with you 💖
@simpletuts4945
@simpletuts4945 3 жыл бұрын
Legend...been trying for an hour!
@idevbrandon
@idevbrandon 3 жыл бұрын
Thank you, Ania. Made it so clear for understanding React
@aniakubow
@aniakubow 3 жыл бұрын
you're very welcome! More react to come :D
@ajayagrawal1090
@ajayagrawal1090 2 жыл бұрын
Even though I utilise Redux/RTK for state management among projects. But yes this trick is also being used constantly. Sometimes I don't even utilise them until and unless problem becomes bigger enough
@kenilbhanderi8933
@kenilbhanderi8933 3 жыл бұрын
Thank you ania for helping to solve my doubt it's very helpful Thank You very much.
@nurammarnaufal7351
@nurammarnaufal7351 Жыл бұрын
ohh babe, this is what i looking for n the easiest turorial 🥺🥺. thanks alot
@isaacdanieltordecillaferia4730
@isaacdanieltordecillaferia4730 3 жыл бұрын
I just looked at all your content, I am a fan of its potential in the area of programming and the ease with which you explain it, that's great. Greetings from Colombia :-D
@aniakubow
@aniakubow 3 жыл бұрын
thanks so much!!!! Hello form London :)
@ScottSpencePlease
@ScottSpencePlease 3 жыл бұрын
Love it! inb4 "well actually"!!! 😂
@aniakubow
@aniakubow 3 жыл бұрын
haahah I'm SO still expecting a 'well I think you will find'
@ThePixelitomedia
@ThePixelitomedia 3 жыл бұрын
ahhhhhh gorgeous Ania is back!
@nxtalex10
@nxtalex10 6 ай бұрын
Thanks !!!!!!!!!!!!!!!!!!!!!!!!! I was losing my mind over this! Thanks thanks thanks thanks
@aniakubow
@aniakubow 6 ай бұрын
Any time !
@redwan_lmati
@redwan_lmati 3 жыл бұрын
this was really helpful, thank you!!!
@khaledmuhammed4225
@khaledmuhammed4225 Жыл бұрын
awsome ania you explantion is fantastic thanks alot
@JamesQQuick
@JamesQQuick 3 жыл бұрын
I use this all the time! Great tip!!
@raulcubila5877
@raulcubila5877 3 жыл бұрын
haha I saved your video cause I knew one day I'd need it. Thanks!!!
@PandamoniumZA
@PandamoniumZA 2 жыл бұрын
This just saved me! Thanks a ton!
@JeremiahPeoples
@JeremiahPeoples 3 жыл бұрын
Does unidirectional data flow mean nothing to you 😂😂😂
@MAT23154
@MAT23154 3 жыл бұрын
Ha! Exactly what I was looking for! Being new to react, I didn't figure out I could pass methods as props. This is very handy. Thank you! You explain very well and this video's rhythm is perfect.
@milosz9668
@milosz9668 Жыл бұрын
Love your videos!
@notbarbara2647
@notbarbara2647 3 жыл бұрын
Solid video mate, cheers.
@LilithinMerria
@LilithinMerria 2 жыл бұрын
Thank you so much for this. It helped a lot ^^
@pazuzutru-truluv7094
@pazuzutru-truluv7094 2 жыл бұрын
Thank you. I was tearing my hair out, which if you are as bald as I am you cannot do for long!
@tusharyewale8645
@tusharyewale8645 3 жыл бұрын
I think it is called as passing function through props or like props drilling. It works well but what if we have some grand childs or if we have more functions which we need to pass child, we need to pass through all the components inbetween which is un necessary. I think it will be better we use hooks or state management tool like redux
@kishoreandra
@kishoreandra 3 жыл бұрын
You are the one of few who looks straight at camera lens while recording and it's Great .... 😜
@aniakubow
@aniakubow 3 жыл бұрын
Haha thanks for noticing! Sending love
@kishoreandra
@kishoreandra 3 жыл бұрын
@@aniakubow 🤝🤝is like a fan moment.... Ania(Barbie of js ) ...
@CamVroM
@CamVroM 3 жыл бұрын
Ania, How can I pass multiple values ​​through the onchange() event in different "input text" from the child component to the parent component? Following the logic of passing setFunction through props? very thankful, Greetings teacher!
@GuitarreroDaniel
@GuitarreroDaniel 3 жыл бұрын
Amazing trick! Just tried it and works like a charm, thanks for sharing!
@aniakubow
@aniakubow 3 жыл бұрын
Any time! Glad I could share something with you :)
@FrankDase
@FrankDase 3 жыл бұрын
Is there a way to do the same without clicking a button or filling an input field? I call my change function within the return part and get the error: cannot update a component while rendering a different component
@FrankDase
@FrankDase 3 жыл бұрын
I found the answer. I my component I have to use "useEffect".
@vaibhavyadav8726
@vaibhavyadav8726 3 жыл бұрын
Exactly what I was looking for.
@aitor.online
@aitor.online 3 жыл бұрын
exactly what i needed. super helpful!
@carlogustavovalenzuelazepe5774
@carlogustavovalenzuelazepe5774 2 жыл бұрын
Could you do this but with inputs that change their value depending on the state like input type range, or something
@codefinity
@codefinity 2 жыл бұрын
0:12 🤓nerd impression! 😆👏
@abdullah5ahmad
@abdullah5ahmad 3 жыл бұрын
this is simple but still a smart way to change parent state! thank you 😄
@developerkim2042
@developerkim2042 3 жыл бұрын
Thank you So Much I Love Your Code Wow~
@holicneko1668
@holicneko1668 3 жыл бұрын
I really like your accent! and the content. helful. thanks from Vietnam
@metamedian
@metamedian 3 жыл бұрын
Wow, thank you for this hack!
@advitiyachouhan5898
@advitiyachouhan5898 2 жыл бұрын
TNice tutorials is going in my helpful tutorials playlist.
@ArshdeepSingh-rs6jn
@ArshdeepSingh-rs6jn 2 жыл бұрын
What a great video. Very concise and straight to the point
@jongartv5726
@jongartv5726 2 жыл бұрын
thank you, very good video
@MrArthurRibeiro
@MrArthurRibeiro 2 жыл бұрын
Great vídeo!!! Best teacher!!!
@andraddedan
@andraddedan 2 жыл бұрын
Thank you so much, very thanks for this video!
@vakasghulamnabi9259
@vakasghulamnabi9259 3 жыл бұрын
I am still learning react. Your Video just made my world a lot easy
@connorvannostrand5764
@connorvannostrand5764 2 жыл бұрын
How do you pass a Function as a prop but also other props as well? My child component has other props that I need to yse
@bissen
@bissen 2 жыл бұрын
Just what I needed! I now just have one challenge... I need to click twice for state to actually update (I'm changing the background color with an onClick). Why is this?
@Sinnermane
@Sinnermane 3 жыл бұрын
I LOVE your tutorial, thank you so much for teaching me this one!
@filip23128
@filip23128 2 жыл бұрын
Thanks Ania!
@LemaTechMedia
@LemaTechMedia 3 жыл бұрын
What a great way of changing state inside the parent component! 😁
@joshuacushing2858
@joshuacushing2858 2 жыл бұрын
Super helpful and understandable. Thank you!
@omegart2207
@omegart2207 3 жыл бұрын
i love when you say wherever =)
@aniakubow
@aniakubow 3 жыл бұрын
Thanks for watching ‘wherever’ you are 😛
@omegart2207
@omegart2207 3 жыл бұрын
tnks sooo much much much =D jaja
@umerkhalique9088
@umerkhalique9088 3 жыл бұрын
any way to do this without hooks? i havent learnt hooks yet. also, i saw on another tutorial that you need to make it a class component first which is counterintuitive in istelf as one might want to make it a functional component to follow modern convention.
@beni_swtr
@beni_swtr 3 жыл бұрын
Yes new Video
@aniakubow
@aniakubow 3 жыл бұрын
yeaaa! Hope you like it
@beni_swtr
@beni_swtr 3 жыл бұрын
Yes i have
@baikovamaria5725
@baikovamaria5725 2 жыл бұрын
thanks for the video. isn't that called lifting state up?
@luizuk4
@luizuk4 3 жыл бұрын
amazing content, saves me! a big thanks from brazil!
@aniakubow
@aniakubow 3 жыл бұрын
Thanks for watching!!
@RobsonAlvesJJ
@RobsonAlvesJJ 3 жыл бұрын
Thank you Ania very good.
@sumitmehra5119
@sumitmehra5119 3 жыл бұрын
Thanks for saving my job.
@ericxls93
@ericxls93 2 жыл бұрын
Dudes I love your videos -thank you, but can not see one that covers react for beginners, I’m I missing something?
@zkcoding1132
@zkcoding1132 2 жыл бұрын
more video on props and react in general please.
@bennyhilding2850
@bennyhilding2850 3 жыл бұрын
Hey! Just tried this and it works perfectly. Thank you!!
@mikez5980
@mikez5980 6 ай бұрын
Thank you for help. Easy way to solve my issue :)
@muzafferckay2609
@muzafferckay2609 3 жыл бұрын
Hi, can you cover a tutorial to give answer to this question: should be used constructor function, class or factory function?
@chukwuebukaanyanwu5433
@chukwuebukaanyanwu5433 3 жыл бұрын
Thank you!! You are amazing!
@nikdev8023
@nikdev8023 3 жыл бұрын
Hi from Ukraine 👋 I really like your videos! Thank you!)
@aniakubow
@aniakubow 3 жыл бұрын
greetings from London!
@IAMpHAM18
@IAMpHAM18 3 жыл бұрын
Wow just like that! Thanks!
@genevievenavales2851
@genevievenavales2851 3 жыл бұрын
Thank you so much for this!
@ibraheemhaseeb3660
@ibraheemhaseeb3660 3 жыл бұрын
omg, that was amazing
@nicolasdupere
@nicolasdupere 2 жыл бұрын
Wonderful! Thanks
Learn how to use Props in React in 19 minutes (for beginners)
19:12
Sonny Sangha
Рет қаралды 148 М.
React JS Props and Prop Drilling | Learn ReactJS
25:54
Dave Gray
Рет қаралды 33 М.
Миллионер | 2 серия
16:04
Million Show
Рет қаралды 567 М.
小路飞嫁祸姐姐搞破坏 #路飞#海贼王
00:45
路飞与唐舞桐
Рет қаралды 28 МЛН
规则,在门里生存,出来~死亡
00:33
落魄的王子
Рет қаралды 30 МЛН
How to hide your API keys SAFELY when using React
24:45
Code with Ania Kubów
Рет қаралды 171 М.
Modern Data Fetching in React (Complete Guide)
16:41
Cosden Solutions
Рет қаралды 54 М.
6 State Mistakes Every Junior React Developer Makes
15:53
Lama Dev
Рет қаралды 267 М.
React Props are Easy
18:05
Sam Meech-Ward
Рет қаралды 9 М.
Change parent state from child components in React/NextJS
10:30
Digital CEO
Рет қаралды 6 М.
Beginner React.js Coding Interview (ft. Clément Mihailescu)
36:31
Ben Awad
Рет қаралды 2,1 МЛН
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 480 М.
How to Learn to Code FAST (Do This or Keep Struggling)
11:00
Andy Sterkowitz
Рет қаралды 710 М.
State Managers Are Making Your Code Worse In React
13:33
Web Dev Simplified
Рет қаралды 189 М.