<commit_before>---
id: migrating-v2
title: Migrating from v1.x to v2.x
---

## Breaking Changes

### Minimum Requirements

- Since Formik 2 is built on top of React Hooks, you must be on React 16.8.x or higher
- Since Formik 2 uses the `unknown` type, you must be on TypeScript 3.0 or higher (if you use TypeScript)

**There are a few breaking changes in Formik 2.x.** Luckily, these probably won't impact many people:

### `resetForm`

Because we introduced `initialErrors`, `initialTouched`, `initialStatus` props, `resetForm`'s signature has changed. It now accepts the next initial state of Formik (instead of just the next initial values).

### `setError`

Please use Formik's `setStatus(status)` instead. It works identically.

### `validate`

As you may know, you can return a Promise of a validation error from `validate`. In 1.x, it didn't matter if this promise is resolved or rejected as in both cases the payload of the promise was interpreted as the validation error. In 2.x, rejection will be interpreted as an actual exception and it won't update the form error state. Any validation function that returns a rejected promise of errors needs to be adjusted to return a resolved promise of errors instead.

### `ref`

Currently, you can't attach a ref to Formik using the `ref` prop. However, you still can get around this issue using the prop `innerRef`. We have some WIP [#2208](https://github.com/jaredpalmer/formik/issues/2208) to instead use `React.forwardRef`.

**v1**

```tsx
resetForm(nextValues);
```

**v2**

```tsx
resetForm({ values: nextValues /* errors, touched, etc ... */ });
```

### `isValid`

This property does not take the value of `dirty` into account anymore. This means that if you want to disable a submit button when the form is not `dirty` (i.e. on first render and when values are unchenged), you have to explicitly check for it.

```tsx
<button disabled={!isValid || !dirty} type="submit">
  Submit
</button>
```

### Typescript changes

#### `FormikActions`

**`FormikActions` has been renamed to `FormikHelpers`** It should be a straightforward change to import or alias the type

**v1**

```tsx
import { FormikActions } from 'formik';
```

**v2**<commit_msg>Fixed a little typo in docs (#2640)<commit_after>---
id: migrating-v2
title: Migrating from v1.x to v2.x
---

## Breaking Changes

### Minimum Requirements

- Since Formik 2 is built on top of React Hooks, you must be on React 16.8.x or higher
- Since Formik 2 uses the `unknown` type, you must be on TypeScript 3.0 or higher (if you use TypeScript)

**There are a few breaking changes in Formik 2.x.** Luckily, these probably won't impact many people:

### `resetForm`

Because we introduced `initialErrors`, `initialTouched`, `initialStatus` props, `resetForm`'s signature has changed. It now accepts the next initial state of Formik (instead of just the next initial values).

### `setError`

Please use Formik's `setStatus(status)` instead. It works identically.

### `validate`

As you may know, you can return a Promise of a validation error from `validate`. In 1.x, it didn't matter if this promise is resolved or rejected as in both cases the payload of the promise was interpreted as the validation error. In 2.x, rejection will be interpreted as an actual exception and it won't update the form error state. Any validation function that returns a rejected promise of errors needs to be adjusted to return a resolved promise of errors instead.

### `ref`

Currently, you can't attach a ref to Formik using the `ref` prop. However, you still can get around this issue using the prop `innerRef`. We have some WIP [#2208](https://github.com/jaredpalmer/formik/issues/2208) to instead use `React.forwardRef`.

**v1**

```tsx
resetForm(nextValues);
```

**v2**

```tsx
resetForm({ values: nextValues /* errors, touched, etc ... */ });
```

### `isValid`

This property does not take the value of `dirty` into account anymore. This means that if you want to disable a submit button when the form is not `dirty` (i.e. on first render and when values are unchanged), you have to explicitly check for it.

```tsx
<button disabled={!isValid || !dirty} type="submit">
  Submit
</button>
```

### Typescript changes

#### `FormikActions`

**`FormikActions` has been renamed to `FormikHelpers`** It should be a straightforward change to import or alias the type

**v1**

```tsx
import { FormikActions } from 'formik';
```

**v2**
{'fraction_non_alphanumeric': 0.10546522131887985, 'fraction_numerical': 0.012195121951219513, 'mean_word_length': 4.381530984204131, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3205062', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1247, 'n_words': 629}