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

Remove outdated comment about Parcel workaround #168

Merged
merged 1 commit into from Jul 4, 2023

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Jul 1, 2023

Those should no longer be needed. If you want to set those explicitly to aid React DevTools in production then I think the as any cast is still a preferred approach but for different reasons. TS isn't able to infer from functions with properties so some HOC-like/FP patterns don't work with React.FC-like types (see the thread here). It's best to keep those as plain functions if possible at type-level (note that components using forwardRef are already breaking that rule because the return type of forwardRef is a function with extra properties. You can't do much about that though unless you'd be ready to use some casts with types like this)

@vercel
Copy link

vercel bot commented Jul 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-resizable-panels ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2023 8:54pm

// Workaround for Parcel scope hoisting (which renames objects/functions).
// Casting to :any is required to avoid corrupting the generated TypeScript types.
// See github.com/parcel-bundler/parcel/issues/8724
(PanelGroupContext as any).displayName = "PanelGroupContext";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, this one might still be needed because JS engine can't infer a name here. Context isn't a function.

@bvaughn
Copy link
Owner

bvaughn commented Jul 2, 2023

Most of these (not counting the context) aren't "needed", but I think the disambiguation in React DevTools is kind of a nice trade-off for the few extra bytes they cost.

@Andarist Andarist force-pushed the fix/remove-parcel-workarounds branch from 43313cc to 6e68158 Compare July 2, 2023 20:54
@Andarist Andarist changed the title Remove explicit .displayNames used as a workaround for Parcel Remove outdated comment about Parcel workaround Jul 2, 2023
@Andarist
Copy link
Contributor Author

Andarist commented Jul 2, 2023

Sure, the thing that caught my eye was the comment - and not the .displayName per se. I pushed out a change to just remove the comment.

@bvaughn bvaughn merged commit 82b3609 into bvaughn:main Jul 4, 2023
6 checks passed
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.

None yet

2 participants