Closed SEovaldi closed 1 year ago
Looks like you didn't define props
for the function:
const ScrollContainer = (props) => { // now you can do stuff with props }
If you need more help please link a codebase so I can see more details but I think this would fix the issue you're having.
same problem here since the error said it missed 'children' on ParallaxProvider props
const ScrollContainer = (props: { children: ReactNode }) => {
const [scrollEl, setScrollElement] = React.useState<HTMLElement>()
const ref = React.useRef<HTMLDivElement>(null)
useEffect(() => {
setScrollElement(document.body)
}, [])
return (
<div className="your-scroll-container" ref={ref}>
<ParallaxProvider scrollContainer={scrollEl}>
{props.children}
</ParallaxProvider>
</div>
)
}
it only append when scrollContainer is set
I have the same issue. it seems <ParallaxProvider>
Doesn't like children if a scrollContainer
is set @jscottsmith
const modalRef = useRef<HTMLDivElement>(null)
...
<ParallaxProvider scrollContainer={modalRef.current as HTMLElement}>
<div> .. </div>
</Parallaxprovider>
@geongeorge thanks, published the type update in v3.4.1.
Maybe its because Im using React 18 but Im having trouble duplicating the example for a Scroll Container.
What Im trying to accomplish: I have a div that has a list of items in that overflow: scrolls. So Im trying to have parallax only occur in that div and only when Im hovering over and scrolling it. Scrolling the document body shouldn't have any effect on it.
I believe scroll container is what I want based on the documentation. Im going off of this Docs: https://react-scroll-parallax.damnthat.tv/docs/usage/components/parallax-provider#scroll-container and this example: https://react-scroll-parallax-v3.surge.sh/?path=/docs/components-parallax-vertical-scroll--inside-a-div
So I tried this straight from the docs:
But it gives an error
Essentially it seems if the ParallaxProvider element has either scrollContainer or scrollAxis properties set, then the component throws this error if you try to add any kind of child element. For example:
This throws the error
But this does not
and neither does this
I might just be misunderstanding something simple but any help would be greatly appreciated again to help me achieve something similar to this: https://react-scroll-parallax-v3.surge.sh/?path=/docs/components-parallax-vertical-scroll--inside-a-div
Thank You!