Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render props #16

Closed
Closed

Conversation

Gibbo3771
Copy link

@Gibbo3771 Gibbo3771 commented Sep 3, 2021

This is related to #15 and is more of a proof of concept than anything else. Using a render slot may not be the best way to do this, but it's a good place to start. I would prefer to use a fowardRef and pass that directly to the scroll component like so:

const MyCustomComponent = React.forwardRef(( _props, ref ) => {
  return (
    <div id="outer">
        <div id="inner" ref={ref}></div>
    </div>
  )
})

<ScrollSyncNode component={MyCustomComponent} /> 

However, I am working on an example for the above, until then we have this.

Having the render prop allows the developer to decide which element we want to store a ref for, I have included an example so you can can clone or add my fork remote to your existing project and see what you think.

I am aware this breaks some existing functionality and the typings are poor, I didn't spend to much time on it.

@Gibbo3771 Gibbo3771 closed this Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant