Skip to content
Discussion options

You must be logged in to vote

You'll have to wait for the client to render this, as window is not available on the server or when this page is built.

You could conditionally load this component by checking if typeof window !== 'undefined' then render the component.

Otherwise you could try:

 const bind = useScroll(
    ({ xy: [, y] }) => set({ width: (y / height) * 100 + '%' }),
    { domTarget: typeof window !== 'undefined ? window : null }
  )

As a last resort you could import this ScrollExample component using a dynamic import with srr: false as shown in the docs

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Tatametheus
Comment options

Answer selected by rafaelalmeidatk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants