Skip to content

Scroll from child component #13

@vebits

Description

@vebits

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}); }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions