Scroll from child component
Hi,
I have a parent and a child component. I want to have a button in the child component which onclick calls a function in the parent component. Inside this function I have the scrollToComponent method.
Inside the render method in the parent class I have this
<Home scroll={this.scrollToBooking} />
and in my child I have this
<button className="book-button" onClick={() => props.scroll()}>ORDER NOW</button>
The scroll() method does get executed but the scrolling is not working, anybody know why or is it another way to do this?
scrollToBooking looks like this:
scrollToBooking() { scrollToComponent(this.Booking, { offset: 0, align: 'top', duration: 1000}); }
I am also trying to trigger the scrolling from a child component, any chance you figured something out?
Got it working by passing a function from the parent component to the child for the button and calling scrollToX() from there. Works but is a bit choppy though that may be something on my end.
+1
@vebits @JourdanLieblich Did you find any solution to this? I am also stuck at same thing. I am able to execute the function but scrolling is not working.