Build forms in React, without the tears ๐Ÿ˜ญ

Comments
  • Formik does not re-render when initialValues change

    Formik does not re-render when initialValues change

    Current Behavior

    If there is an "external" component controlling initialValues passed to Formik, Formik never updates it. This may be desired behavior, however in my specific case I need to re-render the form (and ideally, warn the user about unsaved changes) with new initialValues. If this is not a bug, any ideas on how to achieve this?

    Steps to Reproduce

    1. Open https://codesandbox.io/s/kworjlq7n3
    2. Toggle between the select options
    3. You will see that all components in the chain re-render with new values, however Formik render never changes initialValues.

    Expected behavior

    When initialValues change, Formik should trigger a re-render and provide new initialValues in its render method.

    CodeSandbox Link: https://codesandbox.io/s/kworjlq7n3

    EDIT: CodeSandbox demonstrates a working solution


    • Formik Version: 1.0.2
    • React Version: 16.3.2
    • TypeScript Version: N/A
    • Browser and Version: Chrome Version 68.0.3440.84 (Official Build) (64-bit)
    • OS: Mac OS 10.13.4
    Focus: Documentation Component: Formik 
    opened by iamvanja 111
  • [v2] Hooks

    [v2] Hooks

    Improvements

    • [x] Create <Field as> prop (#1406)
    • [x] Add meta prop to <Field children> (#1406)
    • [x] Break out useFormik from <Formik>
    • [x] onReset and handleReset tests
    • [x] async onSubmit (no more setSubmitting(false) needed)
    • [x] Make validation cancellable (#1026, #671)
    • [x] useField's second element is field metadata (#343)
    • [x] Add initialErrors, initialTouched, initialStatus (#1410)
    • [x] Fix isValid (#1410)
    • [ ] <Field >'s uses handleBlur('path') and handleChange('path') override (#1113)
    • [x] Upgrade to TypeScript 3.5 and React 16.9 (#1559)

    Breaking Changes

    • Breaking TypeScript change: FormikActions have been renamed to FormikHelpers
    • Formik no longer uses console.error in its warnings, but rather console.warn

    Deprecations

    These are just warnings for now.

    • [x] <Field render> (#1406)
    • [x] <Field component> (#1406)
    • [x] isInitialValid and fix isValid (#1410)

    Documentation

    • [ ] useField
    • [ ] "Creating your own <FieldGroup>"
    • [ ] Checkboxes and Radio inputs
    • [ ] <FormikConsumer>
    • [ ] useFormikContext
    • [ ] useFormik
    • [ ] Rewrite examples with hooks
    • [ ] Rewrite tutorial with hooks
    • [ ] Migration Guide
    • [ ] Blog post

    Feel free to start making PR's to this branch. This is going to take a minute to figure out as there are a LOT of new paradigms.

    #1046 #1005

    opened by jaredpalmer 67
  • setFieldValue should return a Promise or receive a callback

    setFieldValue should return a Promise or receive a callback

    Feature

    Current Behavior

    setFieldValue() is async because it uses setState(), but it doesn't receive a callback or return anything. That's why it's hard to get modified values right after that, for example if I want to run submitForm().

    Desired Behavior

    setFieldValue() will return a promise, so I could await it and get changed values.

    Suggested Solutions

    return a Promise from setFieldValue() OR add additional callback to function declaration

    • Formik Version: 0.11.11
    • React Version: 16.2.0
    • CodeSandbox Link: https://codesandbox.io/s/x9445yl5lp
    Type: Enhancement Priority: Medium 
    opened by today- 64
  • Added nested values proposal prototype (#202)

    Added nested values proposal prototype (#202)

    This is my quick suggestion to solve issue #202 . It is far from perfect (I don't use Typescript so I neglected types), also, I couldn't make lodash/fp working with Typescript, so I needed to use mutable _.set, and sadly I used it with deepClone. Of course this would need to be refactored, but this is just a prototype.

    If you like this idea, we could work on it more, add missing tests etc.

    The good news is, that all tests are passing so it is backward compatible change :)

    Type: Enhancement in progress 
    opened by klis87 62
  • Initial validation or initialErrors prop

    Initial validation or initialErrors prop

    What if the user has set some field values, and we do store them somewhere, and when the user returns to the app those values are invalid. Is there no way to run validate on initialization?

    Type: Enhancement Priority: Medium 
    opened by morgs32 50
  • How does yup's trim work?

    How does yup's trim work?

    I tried adding trim() to my formik validation schema:

    Yup.object().shape({
        label: Yup.string().trim().required('some error msg'),
    });
    

    But the field value is not being trimmed.

    opened by sketchbuch 46
  • Extend setValue functionality

    Extend setValue functionality

    Formik is great, but there are one or two parts where the methods could be a little more TypeScript friendly, and in this PR I'm introducing a new method which I hope takes a step in this direction.

    For context: I have a form where a user can enter an ID into a field to perform a lookup. Data is fetched over HTTP, and I use data from the response to populate other form fields by using multiple setFieldValue calls. The signature of setFieldValue isn't type-safe โ€“ย the value is any, and the field may not necessarily exist. (There was some discussion of this in #1388)

    This PR introduces a setFieldValues method that takes a Partial<Values> and merges that with the existing form values. I would find this really useful.

    Things that I'm not too sure about, and that I'd welcome feedback on:

    • Does this method go against the design of Formik, where fields are referenced using the path-style string (eg. people.0.first_name)?
    • Is there a better name for this method, than setFieldValues? It's basically like setValues, but it allows subsets and merges rather than overwriting.
    Type: Enhancement stale 
    opened by samstarling 43
  • Using styled components with formik is incredibly slow

    Using styled components with formik is incredibly slow

    I'm just playing with formik library and found performance issue with custom component in Field tag when the custom component uses styled components heavily.

    When I keep pressing the key in an input box which is wrapped in multiple hierarchy of styled components, it causes huge lagging but instead of that, if I use simple divs, it is comparatively faster.

    Type: Question done 
    opened by mjangir 43
  • v2.0 Umbrella Issue

    v2.0 Umbrella Issue

    • [ ] Hooks (#1063)
    • [ ] Use JSX generics on <Field<Values>> (#726 , #370)
    • [ ] Add debugger / logger
    • [ ] Begin deprecating dirty, with warning (replaced withisDirty) (#353)
    • [ ] Add submitAttemptCount, submitFailureCount, submitSuccessCount and computed boolean counters? didSubmitSucceed and didSubmitFail or submitFailure / submitSuccess
    • [ ] Add warnings, setFieldWarning, setWarnings (#1001, #389)
    • [x] Async onSubmit (#486 , #500)
    • [x] Ensure that Formik context value is immutable
    • [ ] Promisify or give callbacks to all setFieldXXX functions
    pinned v2 
    opened by jaredpalmer 43
  • Slow on large form.

    Slow on large form.

    I have a large form with 20~30 fields. It seems formik becomes slow when there are large number of fields. It seems to validate every field on every keystroke. Is there a good way to mitigate this issue?

    opened by joonhocho 40
  • Auto touch on submit

    Auto touch on submit

    Bug, Feature, or Question?

    Feature/Question

    Current Behavior

    I only show error messages when a field is touched and has a error message. The problem when clicking submit it should show error messages for all fields but since they are not getting marked as touched no error shows up

    Desired Behavior

    When emitting the handleSubmit event all fields in the form should be touched/there should be a flag that indicates if the form was submitted and not reseted.

    • Formik Version: 0.11.10
    • OS: Mac OS
    • Node Version: v9.5.0
    • Package Manager and version: Yarn 1.3.2
    opened by fkrauthan 38
  • Option to keep the type of typescript object when submitting on handleSubmitFunction in Formik.

    Option to keep the type of typescript object when submitting on handleSubmitFunction in Formik.

    Bug report

    Current Behavior

    interface IUser { name: string; noOfSubjects: number; }

    export default function UserDetails(){ const formikForm = useFormik({ initialValues: {name:"",noOfSubjects:0}, handleSubmit: (values)=> { console.log(values); //Here the noOfSubject values in string i want to pass it as number in payload } }) return(

    //Select input with value in number

    select_input

    ) }

    //Current Output : {name:"testing",noOfSubject:"1"}

    Expected behavior

    In the payload of handle submit i want the values with json like ---- {name:"testing",noOfSubject:1}

    Reproducible example

    Suggested solution(s)

    Additional context

    Your environment

    | Software | Version(s) | | ---------------- | ---------- | | Formik | | React | | TypeScript | | Browser | | npm/Yarn | | Operating System |

    Type: Bug 
    opened by narutodev123 0
  • Issue with formik dependent validation

    Issue with formik dependent validation

    Scenarios like this <Field name="test1" valdiation={validationField}>

    Here we have validationField method, based on the second input filed value we need to set the error of the field of the second input.

    i tried like with validationField(formik: FormikProps) => but it was return as undefiend.

    opened by ramanassvv 0
  • Numeric Keys in field names cause formik to crash the browser

    Numeric Keys in field names cause formik to crash the browser

    Bug report

    Current Behavior

    Crashes the browser

    Expected behavior

    To work the same as when using string keys

    Reproducible example

    <Formik initialValues={{}} onSubmit={(v) => console.log(v)}>
            <form>
              <Field name="kitIds[45345345][1]" placeholder="gello" />
              <Field name="kitIds[45345345][2]" placeholder="gello" />
              <Field name="kitIds[two][3]" placeholder="gello" />
              <Field name="kitIds[two][4]" placeholder="gello" />
              <button type="submit">Submit</button>
            </form>
    </Formik>
    

    Suggested solution(s)

    Should work the same as string keys

    Additional context

    Adding a letter to the keys solves this bug but not an ideal solution, should work the same as string keys

    <Formik initialValues={{}} onSubmit={(v) => console.log(v)}>
            <form>
              <Field name="kitIds[X45345345][1]" placeholder="gello" />
              <Field name="kitIds[X45345345][2]" placeholder="gello" />
              <Field name="kitIds[two][3]" placeholder="gello" />
              <Field name="kitIds[two][4]" placeholder="gello" />
              <button type="submit">Submit</button>
            </form>
    </Formik>
    

    Your environment

    | Software | Version(s) | | ---------------- | ---------- | | Formik | 2.2.9 | React | 18.2.0 | TypeScript | 4.7.4 | Browser | Chromium 108.0.5359.99 | npm/Yarn | npm 8.12.1 | Operating System | Ubuntu 22

    Type: Bug 
    opened by x9sim9 1
Owner
Formium
The headless form builder for the modern web. Creators of Formik.
Formium
๐Ÿ“‹ React Hooks for forms validation (Web + React Native)

English | ็นไธญ | ็ฎ€ไธญ | ๆ—ฅๆœฌ่ชž | ํ•œ๊ตญ์–ด | Franรงais | Italiano | Portuguรชs | Espaรฑol | ะ ัƒััะบะธะน | Deutsch | Tรผrkรงe Features Built with performance and DX in mind

React Hook Form 32.4k Dec 29, 2022
How to submit HTML forms to Google Sheets. (Updated for 2021 Script Editor)

Submit a HTML form to Google Sheets How to submit a simple HTML form to a Google Sheet using only HTML and JavaScript. Updated for Google Script Edito

Levi Nunnink 314 Jan 6, 2023
An open source application to create, manage and embed contact forms on static/dynamic sites with no code

Formify is an open source application that lets you create, manage and embed contact forms on any site without writing code. This project is done as a

Basharath 37 Dec 26, 2022
Finished code and notes from EFA bonus class on building a React project without create-react-app

React From Scratch Completed Code This is the completed code for the EFA bonus class on building a React project from scratch. Included are also markd

Conor Broaders 3 Oct 11, 2021
Tina is an open source editor that brings visual editing into React websites. Tina empowers developers to give their teams a contextual and intuitive editing experience without sacrificing code quality.

Tina is an open-source toolkit for building content management directly into your website. Community Forum Getting Started Checkout the tutorial to ge

Tina 8.2k Jan 1, 2023
Based on pure JS scripts, without relying on native, no need for react-native link, Title / Header / Tabs / Sticky / Screen components can be flexibly configured, among which Tabs / Sticky can slide When it reaches the top, it will be topped.

react-native-scrollable-tabview English | ็ฎ€ไฝ“ไธญๆ–‡ Based on pure JS scripts, without relying on native, no need for react-native link,Title / Header / Tab

null 136 Dec 30, 2022
React Native's Global Alert Component that can be fully customized and without the need of a state.

?? React Native Easy Alert React Native Easy Alert Component. Watch on youtube Easy Alert example app. React Native's Global Alert Component that can

null 9 Feb 21, 2022
Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React.

Recoil ยท Recoil is an experimental set of utilities for state management with React. Please see the website: https://recoiljs.org Installation The Rec

Facebook Experimental 18.2k Jan 8, 2023
Material-UI is a simple and customizable component library to build faster, beautiful, and more accessible React applications. Follow your own design system, or start with Material Design.

Material-UI Quickly build beautiful React apps. Material-UI is a simple and customizable component library to build faster, beautiful, and more access

Material-UI 83.6k Dec 30, 2022
Build blazing fast, modern apps and websites with React

Gatsby v3 โš›๏ธ ?? ?? Fast in every way that matters Gatsby is a free and open source framework based on React that helps developers build blazing fast w

Gatsby 54k Jan 9, 2023
๐ŸŽ A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.

downshift ?? Primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components. Read the docs | See

Downshift 11.1k Dec 28, 2022
Boilerplate to build Cross-Platform Apps with Expo and React Native

Expo and React Native Boilerplate Boilerplate to build Cross-Platform Apps with Expo and React Native What are you going to find in this boilerplate E

Josรฉ Ferrer 26 Apr 29, 2022
Source code for my tutorial on how to build customizable table component with React Table and Tailwind CSS.

React Table + Tailwind CSS = โค๏ธ Source code for my tutorial on how to build customizable table component with React Table and Tailwind CSS. Both parts

Samuel Liedtke 147 Jan 7, 2023
Further split the React Native code based on Metro build to improve performance, providing `Dll` and `Dynamic Imports` features

React-Native Code Splitting Further split the React Native code based on Metro build to improve performance, providing Dll and Dynamic Imports feature

Wuba 126 Dec 29, 2022
A react native component that lets you build a dynamic expandable chips list.

React Native Expandable Chips List A react native component that lets you build a dynamic expandable chips list. Installation Run npm install react-na

Daniel Cocos 13 Sep 23, 2022
Shows how React components and Redux to build a friendly user experience with instant visual updates and scaleable code in ecommerce applications

This simple shopping cart prototype shows how React components and Redux can be used to build a friendly user experience with instant visual updates and scaleable code in ecommerce applications.

Alan Vieyra 4 Feb 1, 2022
Build an App using React, Redux, Node and Sequelize.

Individual Project - Henry Pokรฉmon Objetivos del Proyecto Construir una App utilizando React, Redux, Node y Sequelize. Afirmar y conectar los concepto

Rei Orozco 3 Sep 13, 2022
Edvora App is a web application based on an external API, showing data about different types of products and the user can filter these data by choosing a specific state, city or product name. Build with React.js

Edvora App is a web application based on an external API, showing data about different types of products and the user can filter these data by choosing a specific state, city or product name. Build with React.js

Kyrillos Hany 5 Mar 11, 2022
Capture a famous phrase, download it without hassle and share it with your friends. ๐ŸŽ‰

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Abraham Calsin 2 Mar 8, 2022