If you use this. method and are having trouble testing, you need to render out your component and then pass that function into the render method. If anyone is struggling I can make a video explaining how to test these component correctly.
@johnbeckham6063 жыл бұрын
Would be awesome 😎
@fonzie0070073 жыл бұрын
Can I pass a component inside render? return {render:()} Currently its returning an empty div
@TomDoesTech3 жыл бұрын
@@fonzie007007 Your render function will need to return that component. I don't know your use-case but I suspect there is probably an easier way of doing it.
@LebaneseNostalgia2 жыл бұрын
would be really nice if you can explain why we should be using render in this case? Thanks for the video
@shaikhzaki33582 жыл бұрын
This is like custom hook I think
@adriennobel Жыл бұрын
Just when I was about to give up, I stumbled on this video. Thank you so much. You explained EXACTLY what I sas looking for.
@alextana7462 жыл бұрын
this is by far the best video on the subject with the best implementation
@TomDoesTech2 жыл бұрын
Thank you :)
@brikka2 жыл бұрын
Agreed!
@Hello_VVolf Жыл бұрын
More than 2 hours searching, this is the literally I was looking for. Thanks a lot
@TomDoesTech Жыл бұрын
Glad I could help!
@KalSt2 жыл бұрын
This is just awesome. Short, precise, clear. Liked and suscribed.
@TomDoesTech2 жыл бұрын
Welcome aboard!
@rtc92 жыл бұрын
Tom, I just want to give you a heartfelt thanks for this fantastic video.
@johnbeckham6063 жыл бұрын
Awesome, didn't know about the useFilters method ❤️
@NightlyNewsChat2 жыл бұрын
This is an amazing video, learned things I need to know and found out things I need to learn more about.
@AgitNaeta Жыл бұрын
Explain a lot, clear and short wonderful
@holyfreakinguacamole Жыл бұрын
Thanks to you I can sleep more soundly this evening. (I've been at a roadblock on my bootcamp capstone app for two days!!)
@TomDoesTech Жыл бұрын
Rest up buddy!
@LePhenixGD Жыл бұрын
Exactly what I needed for my React component npm library!
@kevinquinn1918 Жыл бұрын
Thanks. This is exactly what I was looking for. This will make my code much simpler
@himanshushekharsahoo6656 Жыл бұрын
really nice explanation
@selvaganeshm1914 Жыл бұрын
best video. Really helpful Tom 👍
@merthaddad15122 жыл бұрын
That was a smart one! thanks a lot
@netsaosa4973 Жыл бұрын
thanks Tom
@BrightAnyawe25 күн бұрын
I was exhausted and wanted to break off, but your video has saved me a lot of time. But have question here for you. ->Can you explain why you use the useFilter for the component Thanks alot☺☺
@5erd1Ай бұрын
if i made this into a separate component, is there a way that i can pass data into the useFilters function? I am using the second method to make a drop down menu which the list of it should be generated dynamically. so i need to pass the list data into the function and return the selected item, is this the way to do it or am i overcomplicating it
@evanvarozza771411 күн бұрын
Having this same question.
@hermessantos181 Жыл бұрын
thank you, dude
@taoaleixandre20893 жыл бұрын
life savior bro
@tylertyler9652 жыл бұрын
smart! lesson learned
@tranquangang94202 жыл бұрын
Thank you so much! Very helpful!
@TomDoesTech2 жыл бұрын
Glad it was helpful!
@AleksandrNeo Жыл бұрын
So helpful!
@medusa121 Жыл бұрын
Wow, that is amazing
@tudoralexandruienulescu2214 Жыл бұрын
Glad to see others got it. This was not clear to me. :( For beginners like me you should 1: Give a better overlook of all your code at the beginning of the demo; 2: Your explanation deserved a slower pace or maybe a better use case. All the best!
@TomDoesTech Жыл бұрын
There's no way i could aim this at absolute beginners. You'd need to have some understanding of React to understand what problem this even solves
@HaiderAli-oi5fm3 жыл бұрын
@3:00 I don't get it. We can change the state by setting the state. But in the case of search, greaterThan, lessThan you are just simply returning these variables and accessing them from other components. You are changing their values without setting a state. Can you explain it to me?
@TomDoesTech3 жыл бұрын
Their state is being set in the filters component, then filters returns the values.
@HaiderAli-oi5fm3 жыл бұрын
@@TomDoesTech Thanks
@Emmabartoillustration Жыл бұрын
hmm... It seems like in the second method you just made something some people call "custom hook"🤔 correct me if I get it wrong. Anyway, great explanation! Thanks a lot!!!
@TomDoesTech Жыл бұрын
That is correct
@dr_davinci Жыл бұрын
This works but gives this warning in the console : Warning: Functions are not valid as a React child. This may happen if you return a Component instead of from render. Or maybe you meant to call this function rather than return it. any chance of this method being not correct ?
@TomDoesTech Жыл бұрын
Make sure you're executing the function and returning JSX
@dr_davinci Жыл бұрын
@@TomDoesTech I had a separate file for useComponent , that was not named correctly, naming it useComponent fixed the warning. Though it was still not working as expected , so I just ended up moving the state up to parent component. Thanks for the reply though.
@TomDoesTech Жыл бұрын
@@dr_davinci Yeah, if you can move the state to the parent, that's usually going to be the simplest and best approach. This is just a good trick for when you get stuck
@PlayingCode2 жыл бұрын
what to do when I have input tag as a child component and I want to fetch the value of the input tag from the parent component...there are many child component refrenced in the parent component
@TomDoesTech2 жыл бұрын
Throw your hands up and pray to a higher being. Joking, this probably isn't the pattern you want to use for that.
@AzNWizzy3 жыл бұрын
Thank you Tom!
@yolobuggy2 жыл бұрын
Hey with method 2 if my child component is a choice Selection component, I set it up like you showed so that it will return the current choice that is being selected. Now, what if I want to render the choice list component multiple time, but with different props each time. The way you showed, it only calls the child component once, so if you render it multiple times its just rendering the exact same component multiple times. How would you go about rendering the child multiple times with different props each time?
@kalinduR96 Жыл бұрын
custom hook♥️
@FF-ie6sd2 жыл бұрын
is it a good practice to pass Hooks as props?
@aat5012 жыл бұрын
from my understanding, you would do this if two different areas of your application need access to the same set of information. check out this tree for example (hopefully gets formatted right) root / \ cars body of water / \ / \ \ capacity(ppl) color pools lakes oceans / color say that in this weird example the car has to be the same color as the pool and have the shared need to access some state related to color. since they dont have the same parents, passing down that state would be a bit of a hassle. to get around this, they can both tap into a hook at their respective point in the tree. this means we can bypass the creation of some component housing the 'color-state' as some ancestor to both nodes of cars and pools. meaning less nodes have to pass down this state information as props for their children way down the tree to use.
@FF-ie6sd2 жыл бұрын
@@aat501 Thank you so much! This really helped. Another side question, this feels a lot like redux. Do these two methods have some kind of similar concepts when we try to use same piece of data?
@alvaroaquije25722 жыл бұрын
Just amazing
@azureharris8647 Жыл бұрын
Im confused as to how you would render this in the App.js
@TomDoesTech Жыл бұрын
Didn't I show how to render it in the video?
@arsh_10x7 ай бұрын
write that code in separate file and then call that file in App.js isn't it simple!!
@John2232 жыл бұрын
what if the child component takes props? how would you pass the props from the parent if all you do is {render}?
@TomDoesTech2 жыл бұрын
Pretty sure you can do something like {() => render(myProps)}
@John2232 жыл бұрын
I tried that and it gives me the 'myProps' is not defined error {() => render( iName='username' iText='test' )}
@TomDoesTech2 жыл бұрын
@@John223 Use an object? That's not even valid JS?
@TomDoesTech2 жыл бұрын
@@John223 Here's an example of how to do it: codesandbox.io/s/dark-star-0vyoep?file=/src/App.js
@rahulmakwana6632 жыл бұрын
This is what iwas looking you saved my hours
@khestal2 жыл бұрын
From the beginning I'm confused, I have not found a consistent answer to why an object is a parent and why another object is a child. In this video, for example, they are just named parent and child, why? why not, I guess.
@TomDoesTech2 жыл бұрын
A parent component is responsible for rendering its children. If a compone is rendered from another component, the component that renders it is considered it's parent.
@codewithhaider71903 жыл бұрын
how to pss the data from child to parent if the click button in parent Plz give me answer
@KCrossReal3 жыл бұрын
Make the child a custom hook, then you can access the child data in the parent. const Parent = () => { const { dataFromChild } = useChild(); return ( dataFromChild() } > Access Child ); }
@dylexbenji2 жыл бұрын
dope 👍🏼
@Momosun2018 Жыл бұрын
@1:28 "pass the props down from the child to the parent" confused me for a second.
@edtechbymeera2 жыл бұрын
I thought its only possible to pass props from parents to child. is it possible vice-versa?
@TomDoesTech2 жыл бұрын
If you watch the video you'll find out
@williamjames68543 жыл бұрын
feedback : audio is so so low brother, make it louder by your mike aur like by the help of software. I am not able to hear anything in my all device without earphone
@TomDoesTech3 жыл бұрын
Thanks for the feedback. I've listened to it back on several devices and the audio is fine.
@rootriger9123 жыл бұрын
nicely explained. thanks
@imrsuv Жыл бұрын
perfect
@saadbelghiti8150 Жыл бұрын
ty bro
@TomDoesTech Жыл бұрын
yw bro
@sayamajmal8094 Жыл бұрын
Subbed
@obas-plays6059 Жыл бұрын
voice output is too low
@KendaBeatMaker Жыл бұрын
Wow
@tipfertilizer45952 жыл бұрын
Your video is very silent
@juhandvan2 жыл бұрын
cool :vv
@rajkumar-nq2te3 жыл бұрын
Great
@programmer69532 жыл бұрын
i did not understand anything from that video as a beginner ,im disappointed
@TomDoesTech2 жыл бұрын
This video isn't for beginners
@programmer69532 жыл бұрын
@@TomDoesTech thanks for answer though,i think ill nevet be able to understand the react,the only job i could find is react and i suck at it so..
@yasinduneth2 жыл бұрын
@@programmer6953 as a beginner if you tried this, you're fcked!