TypeError: Cannot read properties of undefined (reading 'current')
Is there an existing issue for this?
- [x] I have searched the existing issues
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Question
Hello,
I'm using next-urql, which has ssr-prepass built in. After upgrading to React 19 and Next.js 15, I'm encountering an issue. According to an urql maintainer, this seems to be related to your library. Could you provide guidance on resolving this?
Thank you!
https://github.com/urql-graphql/urql/discussions/3732#discussioncomment-12246852
Edit 1: I tried some dummy examples on the latest react and next packages and I am still getting the same error
if (typeof window === 'undefined') {
// some dummy element (div) to run prepass on
const element = createElement('div');
await ssrPrepass(element);
}
I understand this is a new issue, but could this get some attention, please? It could be a blocker for many users looking to upgrade. 🙏
I will try to bump you @carbonrobot since you did the React 19 support
@RomanFausek I made a little inspection on the source code and it's due to using react internal features, exactly here: https://github.com/FormidableLabs/react-ssr-prepass/blob/e48a7788e3386719a82b507f3aa0ba5f28efbdd1/src/visitor.js#L75
react team warned to never use this on production and now in react 19 they removed ReactCurrentDispatcher from the internals which react-ssr-prepass heavily depends on it
Yeah, I get it. The sad part is that our entire codebase was originally built around it by the devs before me. I went ahead and did the necessary refactor