Skip to content

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

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

Conversation

kidonng
Copy link
Contributor

@kidonng kidonng commented May 8, 2025

Currently, with the following code:

<AppForm>
  <ContainerForm>
    <AppField name="animal">
      {() => <RadioGroupField {...props} />}
    </AppField>
  </ContainerForm>
</AppForm>

Storybook's "Show code" function displays "No Display Name" for <AppForm> and <AppField>:

Screenshot 2025-05-08 at 1 17 07 PM

By assigning a displayName, they are displayed with correct names:

Screenshot 2025-05-08 at 1 16 20 PM

Assigning displayName is necessary as merely this:

    const AppForm = useMemo(() => {
-      return (({ children }) => {
+      const AppForm = (({ children }) => {

would display as <AppForm2> instead since it is renamed when compiled:

const AppForm = useMemo(() => {
  const AppForm2 = ({ children }) => {
    return /* @__PURE__ */ jsx(formContext.Provider, { value: form, children });
  };
  AppForm2.displayName = "AppForm";
  return AppForm2;
}, [form]);

Copy link

nx-cloud bot commented May 8, 2025

View your CI Pipeline Execution ↗ for commit 714de59.

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 2m View ↗
nx run-many --target=build --exclude=examples/** ✅ Succeeded 5s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-08 05:40:07 UTC

Copy link

pkg-pr-new bot commented May 8, 2025

More templates

@tanstack/angular-form

npm i https://pkg.pr.new/@tanstack/angular-form@1491

@tanstack/form-core

npm i https://pkg.pr.new/@tanstack/form-core@1491

@tanstack/lit-form

npm i https://pkg.pr.new/@tanstack/lit-form@1491

@tanstack/react-form

npm i https://pkg.pr.new/@tanstack/react-form@1491

@tanstack/solid-form

npm i https://pkg.pr.new/@tanstack/solid-form@1491

@tanstack/vue-form

npm i https://pkg.pr.new/@tanstack/vue-form@1491

@tanstack/svelte-form

npm i https://pkg.pr.new/@tanstack/svelte-form@1491

commit: 714de59

@kidonng
Copy link
Contributor Author

kidonng commented May 8, 2025

Well... https://github.com/TanStack/form/actions/runs/14899285839/job/41847764667?pr=1491#step:6:185

/home/workflows/workspace/packages/react-form/src/createFormHook.tsx
  278:7   error    This mutates a variable that React considers immutable                                 react-compiler/react-compiler

I am fine without the better displayName.

I also just notice more components like <Subscribe> needs this.

@kidonng kidonng marked this pull request as draft May 8, 2025 05:31
@kidonng kidonng changed the title feat(react-form): add displayName to <AppForm> & <AppField> feat(react-form): add display name to components May 8, 2025
Copy link

codecov bot commented May 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.94%. Comparing base (3fe66dd) to head (714de59).
Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kidonng kidonng marked this pull request as ready for review May 8, 2025 05:42
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.

1 participant