Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React router 7 #297

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

React router 7 #297

wants to merge 5 commits into from

Conversation

rphlmr
Copy link
Contributor

@rphlmr rphlmr commented Nov 23, 2024

👋 This is an upgrade for React Router v7

Notable changes:

  • compilerOptions requires an higher target for Cloudflare (BigInt64Array)

src/session.ts Outdated
Comment on lines 6 to 7
const sessionStorageSymbol = Symbol().toString();
const sessionSymbol = Symbol().toString();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has an issue, Symbol() === Symbol() returns false but Symbol().toString() === Symbol().toString() returns true

If Hono doesn't allow symbols anymore, then these needs to be unique strings

Copy link

@lhr0909 lhr0909 Nov 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on my end during react-router v7 migration using this branch and locally patching it back to Symbol(), and verified that Symbol() works just fine. My hono version is v4.6.11 (latest as of now)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has an issue, Symbol() === Symbol() returns false but Symbol().toString() === Symbol().toString() returns true

If Hono doesn't allow symbols anymore, then these needs to be unique strings

Good catch!
To be honest, Hono accepts everything derived from Env: { Variables }, but since we don't pass a type to createMiddleware, it falls back to {string: any}.(https://github.com/honojs/hono/blob/bfc190f72573379565f6fab3f290e657f5778044/src/context.ts#L568).
So, I have added an Env type to pass to createMiddleware and I've checked that the user code doesn't complain about it.

I've rolled back my commit with the string key because it can introduce conflicts if someone uses the same keys in their context.

@lhr0909 Symbol works in JS but the issue here is a pure type error. It would be kind if you could test this version and tell me if you have any issues with Context/Env 🙏

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rphlmr I have tested and it works fine on my end. Thank you!

@rphlmr
Copy link
Contributor Author

rphlmr commented Nov 24, 2024

Let me know if we should rename remix to reactRouter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants