kiliman / remix-typedjson

This package is a replacement for superjson to use in your Remix app. It handles a subset of types that `superjson` supports, but is faster and smaller.
MIT License
435 stars 19 forks source link

Could we make this lib work with Cloudflare Workers platform? #7

Closed supachaidev closed 1 year ago

supachaidev commented 2 years ago

When I use remix-typedjson with Remix + Cloudflare Workers template, there is the following error:

Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
TypeError: Cannot read properties of null (reading 'useContext')
kiliman commented 2 years ago

Do you have a sample repo?

supachaidev commented 2 years ago

Here is the reproduction repo—starting from the official Remix Cloudflare Workers template (only apps/routes/index.tsx was edited).

  1. Clone the repo.
  2. Run pnpm install.
  3. Run pnpm run dev to see the error after visiting the web app in a browser.
shripadk commented 2 years ago

@supachaidev It is probably because of mismatched React versions. Your package.json file has React version pinned to 17.0.2 while remix-typedjson depends on React 18.2.0.

kiliman commented 1 year ago

Hmm.. React and Remix should technically be peer dependencies. Let me see if I can fix the package to make sure it works in all environments.