Description
Feature Request
So that this component could be used with server side rendering (Gatsby is my case), it would be extremely helpful to be able to expose a method as part of the parallaxController
api to update the scrollContainer property on ParallaxProvider
.
In a SSR environment, the reference the the DOM element that is the scrolling container won't be known until componentDidMount
in the parent component of ParallaxProvider
can be called. Even if that is updated via a state change, the ParallaxProvider
is initialized and does not update the scrollContainer
property.
For example, the below does not work, as ParallaxProvider does not update after its first render, so the scrollContainer prop never passes in the updated element stored in the parent components state:
class MyComponent extends React.Component {
componentDidMount() {
const el = /* some code to either user ReactDOM or another method to get the HTML DOM node that is the scroll container. */
this.setState({
scrollContainer: el
})
}
render() {
return (
<ParallaxProvider scrollContainer={this.state.scrollContainer}>
{this.props.children}
</ParallaxProvider>
)
}
}
A simple method to update the scrollContainer on the parallaxController
api would solve this:
parallaxController.setScrollContainer(myelement)