React and Intersection Observer

  Рет қаралды 26,852

Leigh Halliday

Leigh Halliday

Күн бұрын

Пікірлер: 51
@absyas5945
@absyas5945 3 жыл бұрын
Hello Leigh, I just had the urge to pause the video so that I may thank you for this amazing lesson, and your calm style of teaching a complicated topic. THANK YOU!
@leighhalliday
@leighhalliday 3 жыл бұрын
Hey Abs! Thank you so much :) Glad you enjoyed it!
@absyas5945
@absyas5945 3 жыл бұрын
@@leighhalliday I really did, it helped me lazy load an animation, but I've noticed you have to use the triggerOnce option or else you get an undesirable effect (alternates between visible and hidden very quickly at the intersection). Ideally I really would've like it if the animation toggled between the two states smoothly. If you have any tips please let me know, in the mean time THANK YOU once again!
@caleb.39
@caleb.39 3 жыл бұрын
I absolutely love the React community. In my experience most people who do tutorials are so knowledgeable, it's different from other programming languages where the person making the tutorial can seldom explain what they're doing
@missmunmi
@missmunmi 3 жыл бұрын
loved the way you explained. Thank you.. Keep up the good work. Glad I found this video :) Happy coding...
@leighhalliday
@leighhalliday 3 жыл бұрын
Thank you Munmi, glad it helped!
@gamehatred
@gamehatred 3 жыл бұрын
Amazing tutorial, just what I needed to implement Intersection Observer in my project! Subscribed!
@leighhalliday
@leighhalliday 3 жыл бұрын
Awesome! Thanks for subscribing gamehatred!
@gamehatred
@gamehatred 3 жыл бұрын
@@leighhalliday Now I'm watching the google maps and google places video because I need to implement them as well, how are you doing this? :D
@masihqashqai9374
@masihqashqai9374 3 жыл бұрын
What if there are many sections or divs that need to be tracked for intersection? Your method only works for tracking one element intersection right?
@mahakal76
@mahakal76 4 жыл бұрын
loving your videos man I've learned alot from you, I hope you keep putting out the great react content.
@leighhalliday
@leighhalliday 4 жыл бұрын
Thank you mahakal!! That's awesome! More vids on the way 👀
@chany0033
@chany0033 5 жыл бұрын
Interesting demo! , nice to see you again.
@leighhalliday
@leighhalliday 5 жыл бұрын
Thanks, Chany! Life is busy right now so it's hard to put out a lot of content but I'm doing my best :)
@okaforirene2610
@okaforirene2610 3 жыл бұрын
Your content is always so helpful. Keep up the amazing work
@leighhalliday
@leighhalliday 3 жыл бұрын
Thank you very much Okafor!
@janisdregeris248
@janisdregeris248 2 жыл бұрын
Thank You so much, perfect explanation! 👍
@leighhalliday
@leighhalliday 2 жыл бұрын
Glad you enjoyed it!
@yashpandey9550
@yashpandey9550 4 жыл бұрын
Great content. Absolutely loved it. :)
@leighhalliday
@leighhalliday 4 жыл бұрын
Thanks Yash! Glad you enjoyed it!
@nitin-goyal
@nitin-goyal 3 жыл бұрын
Awesome explanation man!
@leighhalliday
@leighhalliday 3 жыл бұрын
Thank you nitin!
@huracan311
@huracan311 3 жыл бұрын
thanks! great explanation
@leighhalliday
@leighhalliday 3 жыл бұрын
Thank you Andres!
@gamspi9591
@gamspi9591 2 жыл бұрын
Thank You
@henokzelalem1964
@henokzelalem1964 3 жыл бұрын
thanks man helped a lot!
@leighhalliday
@leighhalliday 3 жыл бұрын
Nice! Glad I could help :)
@sebastiantramper3260
@sebastiantramper3260 3 жыл бұрын
Thank you for this great explanation of the intersection observer! further more i am looking into using multiple sections. Any ideas how to do that?
@danihazler
@danihazler 4 жыл бұрын
Thanks for that!!! Just wondering if this could be done as a HOC, so when applying to multiple sections wouldn't need to set a ref to each one of them.
@leighhalliday
@leighhalliday 4 жыл бұрын
Hmmm... I'm not sure! I'd be tempted to try to do it as a custom hook rather than an HOC. I think you would want a ref for each one though no? The intersection obsevrver needs an actual ref to a dom element for it to work.
@danihazler
@danihazler 4 жыл бұрын
@@leighhalliday actually, with the help of your second video (kzbin.info/www/bejne/fYenmqppoaasppI) I've manage to do it! Thannnks! :)
@satindersingh9671
@satindersingh9671 2 жыл бұрын
One more gem
@satindersingh9671
@satindersingh9671 2 жыл бұрын
Whatever topics I struggled with, strangely enough you have video on those. We are like minded
@leighhalliday
@leighhalliday 2 жыл бұрын
Haha glad they are helpful!
@theodoreandrew5755
@theodoreandrew5755 3 жыл бұрын
Like your explanation. It's super clear :) Just one thing that I am still confused is that why do we use setRef instead of just using regular useRef? Thanks :)
@leighhalliday
@leighhalliday 3 жыл бұрын
Honestly I can't remember :D Give it a try with useRef, and if it works, go for it!
@chazkondo
@chazkondo 4 жыл бұрын
subbed
@leighhalliday
@leighhalliday 4 жыл бұрын
Welcome, Chaz!
@haruwiki
@haruwiki 2 жыл бұрын
Do you know if this observer API also works horizontally?
@mantisory
@mantisory 4 жыл бұрын
How would you adjust this to have multiple sections in the page animate separately? I was thinking to set the ref on each element directly, but I think there must be a better way...
@leighhalliday
@leighhalliday 4 жыл бұрын
Hey Byron! Yes, I think you'd need to set up multiple observers, each on their own element (with ref), each animating a specific portion of the page. There is no reason you couldn't adjust this to support many elements.
@mantisory
@mantisory 4 жыл бұрын
@@leighhalliday Thanks. Yeah, I ended up setting references for each section individually using the hook...works well, but just a bit cumbersome. I have a couple ideas though..
@karenabgaryan7846
@karenabgaryan7846 4 жыл бұрын
in real world there is always multiple intersections, so its better to a little change project, because for example i spend lot of time to make this work with arrays, or multiple refs, result its not working, so this is not for deploying, just some hobby project
@leighhalliday
@leighhalliday 4 жыл бұрын
Hey Karen! Thanks for the feedback. I'd say the purpose of this video is to teach concepts... and then you can take them to implement for your exact use-case. If I were building an app, I'd be tempted to use this package which has thought of a lot more edge cases than the one I demo in this video. www.npmjs.com/package/react-intersection-observer
@ironpurush0978
@ironpurush0978 3 жыл бұрын
You should provide line=k to your code as well.
@leighhalliday
@leighhalliday 3 жыл бұрын
Sorry! I do for approximately 96.125% of my videos, but I guess I forgot this one...
@ironpurush0978
@ironpurush0978 3 жыл бұрын
@@leighhalliday It's alright man, it's just that we can read the code for correction.
@window.location
@window.location 4 жыл бұрын
Thank you woked like a charm; super; (It will be nice if you share code via GitHub or Gist)
@leighhalliday
@leighhalliday 4 жыл бұрын
Hey Ajith! Sorry, normally I have code but I don't know where it is for this one...
@cod-newbie9166
@cod-newbie9166 5 жыл бұрын
You use a lot of hooks in your code, this is very intimidating. Is there any special case where a hook must be used? Please i want to know.
@leighhalliday
@leighhalliday 5 жыл бұрын
Hey Emeh! No, hooks are optional, as are class based components, but it seems like React is moving more and more towards being functional (as the recommended approach to components), and if you want state and/or effects (componentDidMount), you'll need to become comfortable with Hooks. The great thing is that in a lot of ways I think it makes it easier once you can get over the initial hump of becoming comfortable with them.
Role-Based Authentication in React (Complete Tutorial)
26:31
Cosden Solutions
Рет қаралды 20 М.
React Intersection Observer (scroll + lazy-load  картинок)
22:10
У ГОРДЕЯ ПОЖАР в ОФИСЕ!
01:01
Дима Гордей
Рет қаралды 7 МЛН
SCHOOLBOY. Мама флексит 🫣👩🏻
00:41
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 6 МЛН
Zombie Boy Saved My Life 💚
00:29
Alan Chikin Chow
Рет қаралды 35 МЛН
A very simplified guide on the Intersection Observer API, with examples
21:47
React & Infinite Scroll - IntersectionObserver
15:36
Leigh Halliday
Рет қаралды 19 М.
Learn Intersection Observer In 15 Minutes
15:32
Web Dev Simplified
Рет қаралды 332 М.
Why I Love useReducer
22:40
Harry Wolff
Рет қаралды 92 М.
Introduction to the Intersection Observer JavaScript API
22:11
Kevin Powell
Рет қаралды 178 М.
Infinitely Load More Data in React with the IntersectionObserver API
17:55
Infinite scrolling in React using Intersection Observer
14:15
Hamed Bahram
Рет қаралды 9 М.
React Fiber Reconciliation: How it Works (Part 1)
13:43
Tejas Kumar
Рет қаралды 10 М.
У ГОРДЕЯ ПОЖАР в ОФИСЕ!
01:01
Дима Гордей
Рет қаралды 7 МЛН