-
-
Notifications
You must be signed in to change notification settings - Fork 460
feat(react-form): add display name to components #1491
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
base: main
Are you sure you want to change the base?
Conversation
View your CI Pipeline Execution ↗ for commit 714de59.
☁️ Nx Cloud last updated this comment at |
Well... https://github.com/TanStack/form/actions/runs/14899285839/job/41847764667?pr=1491#step:6:185
I am fine without the better I also just notice more components like |
displayName
to <AppForm>
& <AppField>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1491 +/- ##
===========================================
- Coverage 88.96% 43.94% -45.02%
===========================================
Files 31 13 -18
Lines 1396 157 -1239
Branches 353 26 -327
===========================================
- Hits 1242 69 -1173
+ Misses 137 77 -60
+ Partials 17 11 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
}, [form]) | ||
|
||
const AppField = useMemo(() => { | ||
return (({ children, ...props }) => { | ||
const AppField = (({ children, ...props }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does const Name = () => {}
add the name to the function? For some reason I only thought that function Name() {}
worked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is easy to verify:
const Component = () => {}
Component.name // Component
Also documented: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#variable_declaration_and_method (not quite the same, but you get the idea)
Thank you @kidonng just ran into this in Storybook docs. |
Currently, with the following code:
Storybook's "Show code" function displays "No Display Name" for
<AppForm>
and<AppField>
:By assigning a
displayName
, they are displayed with correct names:Assigning
displayName
is necessary since merely this......would display as
<AppForm2>
instead since it is renamed when compiled:EDIT: since assigning
displayName
triggers a lint error, I'm resorting to simple named functions.