jaredpalmer / formik

Build forms in React, without the tears 😭
https://formik.org
Apache License 2.0
33.71k stars 2.77k forks source link

Fix value type #3961

Open devcrazygit opened 3 months ago

devcrazygit commented 3 months ago

Form values can also be number, boolean, especially when you customize the form control.

In React Native, I created a new customized form select and the value is number. In this case, this causes error because eventOrTextValue.target or eventOrTextValue.currentTarget is undefined.

if (isString(eventOrTextValue)) {
        // If we can, persist the event
        // @see https://reactjs.org/docs/events.html#event-pooling
        if ((eventOrTextValue as any).persist) {
          (eventOrTextValue as React.ChangeEvent<any>).persist();
        }
        const target = eventOrTextValue.target
          ? (eventOrTextValue as React.ChangeEvent<any>).target
          : (eventOrTextValue as React.ChangeEvent<any>).currentTarget;

Can we fix to support such cases?

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: e70d2ac5468643fba249e8dc22a2ee3bf51f3046

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages | Name | Type | | ------------- | ----- | | formik | Patch | | formik-native | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 3 months ago

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

Name Status Preview Comments Updated (UTC)
formik-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 3:02pm
codesandbox-ci[bot] commented 3 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.