HermanNygaard / react-scroll-to-top

Lightweight button component for scrolling to the top of a page
https://www.npmjs.com/package/react-scroll-to-top
MIT License
61 stars 12 forks source link

Compatibility Issue with Next.js Server Components #55

Open rifaturrana opened 9 months ago

rifaturrana commented 9 months ago

Issue Description:

I am encountering a compatibility issue with the react-scroll-to-top package when using it in conjunction with Next.js server components. The error message suggests a problem related to the use of useState in server components.

Steps to Reproduce:

  1. Include react-scroll-to-top in a Next.js project with server components.
  2. Attempt to use the useState hook provided by the react-scroll-to-top package in a server component.
  3. Observe the error: "⨯ useState only works in Client Components. Add the 'use client' directive at the top of the file to use it."

Expected Behavior:

The react-scroll-to-top package should work seamlessly with Next.js server components, and the useState hook should function as expected.

Additional Information:

Please let me know if there are any suggested workarounds or if there is an estimated timeline for resolving this compatibility issue.

Thank you for your attention to this matter.