Answer the question
In order to leave comments, you need to log in
How to integrate click event with block scroll in react?
Good evening. Please tell me how to properly insert scrolling, the idea is this: clicking on the button - scrolling to the beginning of the next block / to the height of the current one, but .. The error is obvious, it cannot find the home element. it has not been created yet, can I somehow postpone it or does react have its own functions to implement this?
Here is what I tried, thanks:
function scroll() {
return document.querySelector('.textBoxes').scrollTo(0, 400)
}
function createButton(className, text, type) {
if(type !== String) {
return (
<button type={type} className={className} onClick={scroll()}>{text}</button>
)
}
else {
return (
<button className={className} onClick={scroll()}>{text}</button>
)
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question