react-waypoint icon indicating copy to clipboard operation
react-waypoint copied to clipboard

Seems to break React Server Components

Open Kyoss79 opened this issue 2 years ago • 4 comments

Hello,

been using this library up to now. It seems the library is using React Context internally, which breaks the new NextJS App Directory using Server Components.

Kyoss79 avatar Jan 30 '23 11:01 Kyoss79

Hi @Kyoss79! Can you point me where we are using React Context? It's been a while since I was in this codebase so I might be missing something but I can't find it.

I wouldn't be surprised if react-waypoint is incompatible with newer React tech (like NextJS app dir), so one possible solution would be for you to move to IntersectionObserver (either via a library or directly against the browser API).

trotzig avatar Jan 30 '23 13:01 trotzig

By looking through the code, the problem seems to be within "react-is".

c=Symbol.for("react.context"),u=Symbol.for("react.server_context")

Mhmm

Kyoss79 avatar Jan 30 '23 20:01 Kyoss79

I believe that code is part of the react repo: https://github.com/facebook/react/blob/1f5ce59dd7b6869b1a17ede65aa301002ef31d4b/packages/shared/ReactSymbols.js#L21-L24

lencioni avatar Jan 30 '23 20:01 lencioni

i couldn't look any deeper into this and changed react-waypoint for react-intersection-observer.

Kinda sad, I liked your API more.

Kyoss79 avatar Jan 31 '23 09:01 Kyoss79