Git Product home page Git Product logo

formik-antd's Introduction

Build Status GitHub stars npm All Contributors license

Install for ant design 5 (beta)

npm i formik-antd@beta

Install for ant design 4

npm i formik-antd

formik-antd

Simple declarative bindings for Ant Design and Formik.

Core Concept

This library enriches several Ant Design components with a required name: string prop that connects them to a Formik form field. It is quite simple. Instead of importing your form components from antd, you need to import them from 'formik-antd' and set their name prop. Now the component is connected/synced with the corresponding Formik field!

The Ant Design components are feature rich and provide a lot of props to customize their visual presentation. These features and also their apis stay exactly the same. Visit their documentation to learn more.

Example:

import React from 'react'
import { Form, Input, InputNumber, Checkbox } from 'formik-antd'
import { Formik } from 'formik'

function App() {
  return (
    <Formik
      {/* default/initial values are set on the Formik container: */ }
      initialValues={{ firstName: '', age: 20, newsletter: false }}
      render={() => (
        <Form>
          {/* every formik-antd component must have the 'name' prop set: */}
          <Input name='firstName' placeholder='First Name' />
          {/* the rest of the api stays as is */}
          <InputNumber name='age' min={0} />
          <Checkbox name='newsletter'>Newsletter</Checkbox>
        </Form>
      )}
    />
  )
}

Getting started

npm install formik-antd

Add import "antd/dist/antd.css" to your index.js file or check the Advanced setup section

Core Components

Name Props
AutoComplete { name, validate?, fast? } & AutoCompleteProps
Cascader { name, validate?, fast? } & CascaderProps
Checkbox { name, validate?, fast? } & CheckboxProps
Checkbox.Group { name, validate?, fast? } & CheckboxGroupProps
DatePicker { name, validate?, fast? } & DatePickerProps
DatePicker.WeekPicker { name, validate?, fast? } & WeekPickerProps
DatePicker.RangePicker { name, validate?, fast? } & RangePickerProps
DatePicker.MonthPicker { name, validate?, fast? } & MonthPickerProps
Input { name, validate?, fast? } & InputProps
InputNumber { name, validate?, fast? } & InputNumberProps
Input.Password { name, validate?, fast? } & InputPasswordProps
Input.TextArea { name, validate?, fast? } & Input.TextAreaProps
Mentions { name, validate?, fast? } & MentionsProps
Radio.Group { name, validate?, fast? } & RadioGroupProps
Rate { name, validate?, fast? } & RateProps
Select { name, validate?, fast? } & SelectProps
Slider { name, validate?, fast? } & SliderProps
Switch { name, validate?, fast? } & SwitchProps
Table { name, fast? } & TableProps
TimePicker { name, validate?, fast? } & TimePickerProps
Transfer { name, validate?, fast? } & TransferProps
TreeSelect { name, validate?, fast? } & TreeSelectProps

Submitting and Resetting Forms

Directly under each <Formik> container a <Form> component should be placed. This component composes the functionality provided by Ant Designs (https://ant.design/components/form/) as well as Formiks (https://jaredpalmer.com/formik/docs/api/form) <Form> components:

import React from 'react'
import { Form, SubmitButton, ResetButton /* ... */ } from 'formik-antd'
import { Formik } from 'formik'

function App() {
  return (
    <Formik initialValues={/* ... */} onSubmit={/* ... */}>
      <Form>
        {/* ... */}
        <SubmitButton />
        <ResetButton />
      </Form>
    </Formik>
  )
}

The SubmitButton and ResetButton will disable automatically depending on form state. The ResetButton is enabled if the form is dirty. The SubmitButton is enabled if the form is valid or if it is not dirty and the submit count is zero. If you do want to control the disable behavior yourself you can provide the disable: boolean prop. I.e. <SubmitButton disabled={false} /> will make the button always be enabled.

Form- and Field-level Validation

Formik provides form- and field-level validation callbacks to provide validation logic. How to validate is neither part of formik nor of this library.

Form-level validation is done by setting formiks validate prop. Field-level validation is optional available on the components. Additional to the name prop formiks optional validate?: (value: any) => undefined | string | Promise<any> is added to all core components to allow field-level validation. There is one special case to be aware of when using field-level validation: When using the Form.Item component with another Antd field component, the validate prop has to be added to the Form.Item, not the input component:

<Form.Item name='firstName' validate={validator}>
  <Input name='firstName' />
</Form.Item>

Rendering Validation Feedback

Showing validation messages can be accomplished with the Form.Item component (or FormItem which is the same). It

  • renders error messages if the field has been touched and the corresponding field has a validation error (and changes the border color of enclosed input component to red).
  • renders a green success icon messages if it's showValidateSuccess: boolean prop is set to true, the field has been touched and the corresponding field does not have a validation error.
  • exposes some layout features and a label (visit https://ant.design/components/form/ for the details).
<Form.Item name='firstName'>
  <Input name='firstName' />
</Form.Item>

FastField support

Formik allows performance optimizations through the <FastField/> component. Please read the formik docs on when to use such an optimization (usually you don't and maybe should not optimize, unless you encounter performance issues in production). To opt-in to FastField support, all formik-antd components provide an optional fast?: boolean prop. Setting this to true enables the optimization:

<Input name='firstName' fast={true} />

Table

The table components comes with additional helper buttons to add and delete rows. An example can be seen in the codesandbox.

Lists and Nested objects

Nested objects and arrays can be accessed with lodash-like bracket syntax as described in the Formik documentation.

<Input name='friends[0].firstName' />

Advanced setup

You can checkout this github template project get the following setup (and more).

If you do not want to import the full ant design library and its stylesheet (in order to reduce the bundle size) you can import specific components and their stylesheet by their path, as it is described in the antd documentation https://ant.design/docs/react/getting-started#Import-on-Demand

import Input from 'formik-antd/es/input'
import 'formik-antd/es/input/style'

Some build tools like webpack are now able to "tree shake", meaning unused code from ant design will not be bundled.

As writing imports like this is a little cumbersome there is a babel import helper: https://github.com/ant-design/babel-plugin-import. In create-react-app projects babel plugins do not work out of the box. With third party projects like customize-cra and react-app-rewired we are able to change the webpack config. Be warned though, the team behind create-react-app does not support this scenario, so if you run into problems you are on your own.

npm install babel-plugin-import customize-cra react-app-rewired --save-dev

config-overrides.js

const path = require('path')
const { override, fixBabelImports } = require('customize-cra')

module.exports = override(
  fixBabelImports('antd', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: 'css',
  }),
  fixBabelImports('formik-antd', {
    libraryName: 'formik-antd',
    libraryDirectory: 'es',
    style: 'css',
  }),
)

package.json

  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test"
  }

Playground & Contributions

If you want to dig into the source code and test locally you can use https://github.com/jannikbuschke/Formik-antd-playground (clone with the --recursive flag and follow the README, its pretty simple).

TypeScript

Types are included.

Typechecking limitations

Form values currently cannot be typechecked (at least to my knowledge). For example the following ideally would give a compile error:

<Formik<{name:string}> initialValues={{name:""}}>
  <Input name="naem" />
</Formik>

Typescript cannot (yet) enforce types of children. In the future this hopefully will be possible.

Related projects

  • cra-antd-x a template project with react-app-rewired (babel imports, fast-refresh, themeable), typescript and react-router.

License

MIT

Contributors

Special thanks to all contributors:

Nile Daley
Nile Daley

💻
James W Mann
James W Mann

💻
Jannik Buschke
Jannik Buschke

💻
Lars-Jørgen Kristiansen
Lars-Jørgen Kristiansen

💻
Adam
Adam

💻
jeessy2
jeessy2

💻
Pavan Agrawal
Pavan Agrawal

📖
Khartir
Khartir

💻
Yury Kozhenov
Yury Kozhenov

💻
Tonye Jack
Tonye Jack

💻
Edon Gashi
Edon Gashi

🚇
Roman Tsegelskyi
Roman Tsegelskyi

💻
Daniel Schulz
Daniel Schulz

💻
Harry Green
Harry Green

📖
Daniel Huth
Daniel Huth

💻
Gabriel Berlanda
Gabriel Berlanda

💻 📖
Alexandre Giard
Alexandre Giard

🤔
kissthom
kissthom

🐛
Chris Higgins
Chris Higgins

💻
Felipe Lima
Felipe Lima

💻
Frédéric Barthelet
Frédéric Barthelet

💻
Vincent
Vincent

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

formik-antd's People

Contributors

allcontributors[bot] avatar c-higgins avatar denviljclarke avatar dependabot[bot] avatar dmitrienko-nikita avatar edongashi avatar felipeptcho avatar fredericbarthelet avatar gabrielberlanda avatar harrygreen avatar honzahruby avatar jackton1 avatar jannikbuschke avatar jimmyn avatar jwmann avatar khartir avatar kzoeps avatar larsjk avatar niledaley avatar pavanagrawal123 avatar romantsegelskyi avatar voxtex avatar yurykozhenov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

formik-antd's Issues

Html Label (in testing contexts) and a11y behavior not optimal

Can you elaborate a bit which labels you mean exactly?

Sure, here's a forked example of your CodeSandbox: https://codesandbox.io/s/y257p4l8z9

Edit: as a counter-example, look at antd's own CodeSandbox to see how the DOM differs: https://codesandbox.io/s/kw79qx5w15

The label element for [name=userName] does not have a for="userName", which breaks things like react-testing-library's getByLabelText and forces me to fallback to less optimal methods for finding and filling inputs, and breaks some browser / a11y behavior.

I have a feeling this is some sort of props issue, but honestly just have not had time to examine further.

(P.S. Thanks for making this!)

Originally posted by @joshsmith in #23 (comment)

Error using Select component

           My code:           
                      <Select
                        defaultValue="Sunday"
                      >
                        <Select.Option value="Sunday">Sunday</Select.Option>
                        <Select.Option value="Monday">Monday</Select.Option>
                        <Select.Option value="Tuesday" >Tuesday</Select.Option>
                        <Select.Option value="Wednesday">Wednesday</Select.Option>
                      </Select>

Error:
Objects are not valid as a React child (found: object with keys {}). If you meant to render a collection of children, use an array instead.
in div (created by Select)
in div (created by Select)
in div (created by Select)
in div (created by Select)

invoke onChange handlers

To allow custom onChange while still internally updating Formik state, prop onChange should not overwrite existing onChange. Instead, existing (internal) onChange should check if the user onChange is passed as a prop and execute it if so.

So instead of

...
onChange={v => {
  setFieldValue(name, v.target.checked)
  setFieldTouched(name, true)
}}
{...restProps}
...

something like this

...
{...restProps}
onChange={v => {
  setFieldValue(name, v.target.checked)
  setFieldTouched(name, true)
  restProps.onChange && restProps.onChange(v)
}}
...

Originally posted by @iamvanja in #56 (comment)

FormItem isTouched requirement unnecessary and hides actual valid errors

I'm current working on a form that uses both inline and form-wide validation.
I'm trying to cover all cases of someone using the form and trying to pass validation.

One scenario being, someone who doesn't fill out the form of required fields, and just presses submit and/or triggers the validateForm() function.

Using the current state of the FormItem component, even though Formik is legitimately passing proper errors, because the FormItem is checking for isTouched, it won't actually display any of the errors. So the user actually doesn't know why he can't submit (even though there are errors)

This needs to be fixed asap imo

Changing imports to reduce bundle size?

I just spent a couple hours tonight trying to figure out why my import on demand per Ant's docs was not working. Turns out that it was a couple imports from formik-antd.

I wonder if it's possible for formik-antd to import similarly, e.g. instead of import { Form } from 'antd' you would do import Form from 'antd/lib/form' or import Form from 'antd/es/form'.

Thanks in advance!

FormItem evolvement

Currently I am not yet 100% happy with the FormItem component, as

  • providing the name prop is duplicated (FormItem and the Input control need it)
  • creates nesting
  • the default css has a big margin-bottom value (antd issue)
  • FormItem seems to be a little bit overloaded (i.e.g with layout stuff and rendering a label https://ant.design/components/form/, also the ant design samples here look overly complex)
  • I think that either all input components are wrapped in a FormItem or not. If all are wrapped, this seems to be just boilerplate, and it would be nice to have a simple mechanism to enable/disable validation/FormItem-Wrapping

Warning: Invalid value for prop `validate` on <input> tag.

Seem as though you aren't removing validate from the props that you're extending to <Input />.

A simple spread destructure on props should fix this.
It also seems that this applies to the rest of the components as well.

I can make a PR for this tomorrow.
It will follow the same prop destructuring method I used in #7

Add source files as part of npm package

Please add source files to node_modules package, when publishing the package to npm. Because they are not published, I'm unable to inspect the non-compiled source of the package from my editor and my build is throwing warnings because source map files are referring to source files which are not there.

This is the current file stucture:

image

Otherwise, nice lib, I'm having a pleasant time using it so far.

dependency not found lodash.get

Just installed the newer version of this package in my app.

Seems as though putting lodash.get inside the devDependencies is not enough.
Should probably be in dependencies.

npm start

> [email protected] start /Users/jwm/work/app/
> cross-env APP_TYPE=site API_ENV=dev umi dev


Warning: umi-plugin-polyfills has been deprecated.
use config.targets instead.


[hardsource:b8404551] Using 123 MB of disk space.
[hardsource:b8404551] Writing new cache b8404551...
[hardsource:b8404551] Tracking node dependencies with: package-lock.json, yarn.lock, .umirc.js, .umirc.local.js, config/*.

✖ Webpack
  Compiled with some errors in 18.35s

 ERROR  Failed to compile with 2 errors                                                                                         1:52:11 p.m.

This dependency was not found:

* lodash.get in ./node_modules/@jbuschke/formik-antd/lib/FormItem.js, ./node_modules/@jbuschke/formik-antd/lib/ListEditor.js

To install it, you can run: npm install --save lodash.get
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `cross-env APP_TYPE=site API_ENV=dev umi dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jwm/.npm/_logs/2019-04-12T17_52_11_924Z-debug.log

Change names to match Antd component names

In order to make migrations easier and to make the component names simpler, the Field suffix should be dropped.
It's likely that in a specific files (maybe even in a codebase) only exclusively formik-antd or antd components will be used, so the readability/comprehensibility should be granted.

any breaking changes in 1.3?

If anyone by change reads this, can you report if version 1.3 works or has any problems that have not been present in 1.2?

The underlying way of exporting components changed, but there shouldnt be any breaking changes.

Any feedback is appreciated (also just "works")

Radio component as Radio.Button produces "undefined" form items

If I have a Radio.Group on my form, whenever I change the value of the radio it creates a "undefined" attribute in the values object. Part of the behaviour is correct, it changes the value of the category to whichever value I have selected at the time, but also creates a new attribute called "undefined". I have to manually remove to the key from the object to correctly submit the form.

I even created a sandbox to demonstrate the issue: https://codesandbox.io/s/angry-shockley-f513c

Problem validating an Input wrapped by Form.Item

Hi there - thanks for the work on formik-antd!

I'm running into a slight snag - how might I utilize the validate prop on an <Input /> component - all while utilizing a <Form.Item> to wrap it?

I would like to provide a label for a field and perform field-level validation on it, but it looks like if the name property on Form.Item and Input are identical, any errors do not make it up into the Formik state (as shown by the debugger component).

I've provided an example here:
https://codesandbox.io/s/formikantd-j4b4m?fontsize=14

FormItem hide validate success by default

First off, excellent library and exactly what I was looking for. Antd's built-in form leaves a lot to be desired, especially around nested fields and arrays. Formik fills the gap perfectly.

I don't think the the validation success state should be enabled by default. An optional prop (showValidationSuccess) should be accepted by FormItem and only show the green success checkmark if it's true. From my experience and usage of forms showing validation success is more the exception rather than the rule. If you disagree, it can be enabled by default but at least provide an option to hide it.

Will submit a PR if I get some time.

commonjs modules

I would like to use this project next.js but fails at importing components when rendering from server-side. Would there be no problems to change the module target from esnext to commonjs?

Using Antd Table with formik

Hello! Do you have any plans to wrap the Antd Table component? I'm looking to build a form with the ability to add/delete identical objects without using arrays of multiple fields (rather using a table instead). Thanks!

I hope for auto add required to <FormItem/>

const SignupSchema = Yup.object().shape({
    realname: Yup.string().trim().required('realname'),
});
<FormItem name={"realname"} label={'realname'} required>
    <Input name="realname" />
</FormItem>

I hope for auto add required for FormItem

<Select.Option/> support?

Select don't support Select.Option!
I find "Select.renderOptions" in Select.tsx,
But not everybody know this. Because in ant design, we use <Select.Option>

My code:

import {Select} from "@jbuschke/formik-antd";
<Select name='sex'>
 {
  Select.renderOptions([{label:'male', value:'M'}])
 }
</Select>

Checkbox is not set as touched

Consider

<Formik
  ...
  render={() => (
    <Form>
      <FormItem name='rememberMe'>
        <Checkbox name='rememberMe'>
          Remember me
        </Checkbox>
      </FormItem>
    </Form>
  )}
/>

Toggling this checkbox does not set rememberMe field as touched.

Allow Formik 2

Formik 2 is nearing completion and as far as I can tell, there is no reason that formik-antd should not simply work with Formik 2. I did some tests on a project I'm working on and it seems to be working just fine. So I would suggest to increase the allowed Formik version.

SubmitButton disabled when the form has initial values

I have a multi form where you can pick up where you left while filling them out, so at times the initial values I pass to the Form is the values grabbed from the server, The submit button is disabled and doesn't let me submit even when the schema validation is passing, It only let's me when the value of the fields is different from the initial values.

DatePicker not formatting correctly

When using the DatePicker through formik it isn't formatted correctly and also when clicked the datepicker doesn't appear.

With formik-antd
Screenshot 2019-05-18 at 18 50 49

Standard antd
Screenshot 2019-05-18 at 18 51 03

Screenshot 2019-05-18 at 18 51 05

Babel import styles not working in production build

Here is my config-overrides.js:

module.exports = override(
  addLessLoader({
    javascriptEnabled: true,
    modifyVars: {
      hack: `true; @import "${path.resolve(__dirname, './src/theme.less')}";` // Override with less file
    }
  }),
  fixBabelImports('antd', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: true
  }),
  fixBabelImports('formik-antd', {
    libraryName: '@jbuschke/formik-antd',
    style: true,
    libraryDirectory: 'es'
  })
);

Everything is working great with yarn start, but I'm missing styles for formik-antd components when creating a production build (yarn build).

Just saw this comment, which looks like they're having the same issue: #63 (comment)

The next comment in that thread (@edongashi) has suggestions which did not fix the problem.

@thj-dk is your build script in package.json set to "build": "react-app-rewired build"?

Also try setting style: 'css' in fixBabelImports to see if it makes any difference.

Include package.json "module" field

Similar to antd, I think it would make sense to include a "module" field in package.json along with a version of the build that uses ES2015 modules instead of only CommonJS. I was going through the code and I'm not quite clear what your actual build/deploy process is, but the fix should be as simple as:

Create another tsconfig (or use command line flags for tsc) to provide the following options (target ES2015 automatically sets module ES2015)

{ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "./es", "target": "ES2015" } }

Update package.json to point to the new directory

{ "files": [ "lib", "es" ], "module": "./es/index.js" }

Now more advanced bundlers, such as webpack 2 and rollup, will use the module files and can properly tree shake dependencies. This is all my understanding of how this works so it may not be 100%.

Error when using Select component

           My code:           
                      <Select
                        defaultValue="Sunday"
                      >
                        <Select.Option value="Sunday">Sunday</Select.Option>
                        <Select.Option value="Monday">Monday</Select.Option>
                        <Select.Option value="Tuesday" >Tuesday</Select.Option>
                        <Select.Option value="Wednesday">Wednesday</Select.Option>
                      </Select>

Error:
Objects are not valid as a React child (found: object with keys {}). If you meant to render a collection of children, use an array instead.
in div (created by Select)
in div (created by Select)
in div (created by Select)
in div (created by Select)

FastField Support

I'm really happy how this project has evolved, I feel like it's at a really good spot right now. 👍

https://jaredpalmer.com/formik/docs/api/fastfield
This is just a feature request for the future of this package. Could be really useful for some ( I might even try them out for optimization )

I believe the FastField uses the same API as Field so it shouldn't be too crazy to implement.
Not sure if we should make new components for each (but using FastField) or make some kind of switch in the component itself.
Either way, I'd hope it maintains our clean coding standard so far.

Using antd style customization

Getting started documentation says:

Add import "antd/dist/antd.css to your index.js file (or look at https://ant.design/docs/react/getting-started for other options).

And Antd's documentation has:
https://ant.design/docs/react/use-with-create-react-app#Customize-Theme

It also gives the ability to reduce the amount of css code which should be included by adding only used components.
https://ant.design/docs/react/use-with-create-react-app#Advanced-Guides

But when I use formik-antd I lose this and can't customize theme anymore :(

Any solution for that?

Publishing / Testing local formik-antd fork from another Local Project

I was considering adding some PRs but I like to be able to test local changes in my current project prior to submitting the PR.

I know in package.json you can reference another local file / directory as the source of the node module but I tried it and it doesn't seem to build well.
I get errors like

Uncaught TypeError: this.props.formik.registerField is not a function at FieldInner.componentDidMount

If I use the normal package installed via npm itself, I don't get these errors.

Maybe I need to publish / build the project first? Not sure.

Problem with styles with Form component using customize-cra

My config-overrides.js is:

module.exports = override(
  addLessLoader({
    javascriptEnabled: true,
    modifyVars: {
      '@primary-color': constants.colors.Primary,
      '@secondary-color': constants.colors.Secondary,
    },
  }),
  fixBabelImports('antd', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: true,
  }),
  fixBabelImports('formik-antd', {
    libraryName: '@jbuschke/formik-antd',
    style: true,
    libraryDirectory: 'es',
  }),
);

I have a form, where I want to import formik-antd components:

import { Form, FormItem, Input } from '@jbuschke/formik-antd';

Then I receive an error:
Module not found: Can't resolve '@jbuschke/formik-antd/es/form/style'

formik-antd version 1.3.0.

Screenshot from antd:
image

Screenshot from formik-antd:
image

SubmitButton inside form tag with onSubmit handler causes submit handler to be called twice

If I set the htmlType to button, it won't submit twice but form submit using enter key doesn't work anymore.

Sample code:

<Formik initialValues={{ username: "", password: "" }} onSubmit={this.handleSubmit}>
  {props => (
      <form className={styles.login} onSubmit={props.handleSubmit}>
        <FormItem name="email">
          <InputField name="email" placeholder="Email" autoComplete="username"
                      prefix={<Icon type="user" style={{color: 'rgba(0,0,0,.25)'}}/>}/>
        </FormItem>
        <FormItem name="password">
          <InputField name="password" type="password" placeholder="Password" autoComplete="current-password"
                      prefix={<Icon type="lock" style={{color: 'rgba(0,0,0,.25)'}}/>}/>
        </FormItem>
        <FormItem>
          <SubmitButton className={styles.submit} type="primary" htmlType="submit" size="large">
            Login
          </SubmitButton>
        </FormItem>
      </form>
  )}
</Formik>

Submit Button default disabled behavior

It doesn't seem to make sense to disable SubmitButton by default when the form is invalid. What ends up happening is that the form is immediately invalid, and since errors don't show up on fields unless they have been touched (focused or submit button pressed), it is impossible to tell which form fields need to be fixed and you can't click submit to check.

I propose remove isValid check or changing it to (!isValid && submitCount > 0) or something similar.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.