I want to use JS functions like document.getElementById() in my react project. I am new to styled components and don't know how to use these functions with them.
Do not refer to the official 'styled-components' page, I have already seen it.
I want to use JS functions like document.getElementById() in my react project. I am new to styled components and don't know how to use these functions with them.
Do not refer to the official 'styled-components' page, I have already seen it.
You can use useRef react Hook for this.
const reqElement = React.useRef(null);
Now, you can add ref={reqElement} in your required element.
After that you can use reqElement.current to do those things that you can do via document.getElementById() in javaScript.
I have finally found an answer to my question here. I laying down the gathered information in the following points.
Here is a link to a Parallax effect video https://youtu.be/Q5y6pwoE3cM hope this can help you.