So it looks like you're not really storing anything in your refs object. As you can see in my example, ref needs to be attached to html element, like this:
@maciekgrzybek
can you please assist with this, i have literally tried everything i know nothing just works, been on it sice you told me about the forwardref and still not gotten anywhere
Sorry mate, I wish I could help but I'm really busy with my other projects. Everything you need to know should be in this article, basically ref needs to be attached to an actual dom element and currently you just passing them to the components. Some more reading ->
Hi there @maciekgrzybek sorry for disturbing you agai, i found a way to make the scrolling to each section work but then i cant make the io and the active class work, could you please assit me with that in your free time. Here is a codepen link codesandbox.io/s/eager-agnesi-virvq
Sort of, found another way but your method looked really nice also wish I could have broken it down better
Here is a link to what I did with it nba-landing.netlify.app/
You need to observe for each element, now you're not really observing anything. Notice how in my tutorial, each character is a separate component, and each one of them has its own Observer attached to it.
There is no such a thing like refs.name in you code. Console log it and see what you are getting. If you want to access ref with specific name you need to access it with refs[name]. Also, you need to add a observer for each name.
Thanks Maceik, i'll look at your approach again once i am free cus right now tbh i am not really getting what i am doing again cus i had to learn a lot two weeks ago
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I'll take a look later today and will let you know :)
Wow, thanks a lot you are so kind 🙏
this is a link to a codesandbox
codesandbox.io/s/tender-oskar-rvbz...
So it looks like you're not really storing anything in your
refs
object. As you can see in my example, ref needs to be attached to html element, like this:If you want to get the ref from inside of some other component, you'll have to use
forwardRef
-> reactjs.org/docs/forwarding-refs.htmlThat's why you're getting errors
Please is this an issue you could assist me in solving, just started using react of recent and i need this for the project.
I'd be really grateful if you could assist me with this
@maciekgrzybek can you please assist with this, i have literally tried everything i know nothing just works, been on it sice you told me about the forwardref and still not gotten anywhere
Sorry mate, I wish I could help but I'm really busy with my other projects. Everything you need to know should be in this article, basically
ref
needs to be attached to an actual dom element and currently you just passing them to the components. Some more reading ->Thanks, I'd look for an alternative if i cant find a solution, really appreciate 🙏
Hi there @maciekgrzybek sorry for disturbing you agai, i found a way to make the scrolling to each section work but then i cant make the io and the active class work, could you please assit me with that in your free time. Here is a codepen link
codesandbox.io/s/eager-agnesi-virvq
Hey man, sorry wasn't here for a while, did you manage do sort this out?
Sort of, found another way but your method looked really nice also wish I could have broken it down better
Here is a link to what I did with it
nba-landing.netlify.app/
You were really close, you just didn't pass the correct name to activeCharacter state :)
Sorry could you do that and let me see where I made the mistake,probably fork the sandbox and send an updated link. Happy holidays
In this useEffect:
You need to observe for each element, now you're not really observing anything. Notice how in my tutorial, each character is a separate component, and each one of them has its own Observer attached to it.
I keep getting the husband error
Argument 1 ('target') to IntersectionObserver.observe must be an instance of Element
Now I am observing for with refs.name but still getting that error
Now I am observing with refs.name but still getting that error
There is no such a thing like
refs.name
in you code. Console log it and see what you are getting. If you want to access ref with specific name you need to access it withrefs[name]
. Also, you need to add a observer for eachname
.Thanks Maceik, i'll look at your approach again once i am free cus right now tbh i am not really getting what i am doing again cus i had to learn a lot two weeks ago