Skip to content

Commit 31d669d

Browse files
committed
Probably a better type for ref
1 parent d459e29 commit 31d669d

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

packages/formik/src/Formik.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
FieldHelperProps,
1414
FieldInputProps,
1515
FormikHelpers,
16-
FormikContextType,
1716
} from './types';
1817
import {
1918
isFunction,
@@ -138,7 +137,7 @@ export function useFormik<Values extends FormikValues = FormikValues>({
138137
enableReinitialize = false,
139138
onSubmit,
140139
...rest
141-
}: FormikConfig<Values>) {
140+
}: FormikConfig<Values>): FormikProps<Values> {
142141
const props = {
143142
validateOnChange,
144143
validateOnBlur,
@@ -998,7 +997,7 @@ export function useFormik<Values extends FormikValues = FormikValues>({
998997
export const Formik = React.forwardRef(<
999998
Values extends FormikValues = FormikValues,
1000999
ExtraProps = {}
1001-
>(props: FormikConfig<Values> & ExtraProps, ref: React.Ref<FormikContextType<Values>>) => {
1000+
>(props: FormikConfig<Values> & ExtraProps, ref: React.Ref<FormikProps<Values>>) => {
10021001
const formikbag = useFormik<Values>(props);
10031002
const { component, children, render, innerRef } = props;
10041003

@@ -1035,7 +1034,7 @@ export const Formik = React.forwardRef(<
10351034
}) as <
10361035
Values extends FormikValues = FormikValues,
10371036
ExtraProps = {}
1038-
>(props: FormikConfig<Values> & ExtraProps & React.RefAttributes<FormikContextType<Values>>) => JSX.Element;
1037+
>(props: FormikConfig<Values> & ExtraProps & React.RefAttributes<FormikProps<Values>>) => JSX.Element;
10391038

10401039
function warnAboutMissingIdentifier({
10411040
htmlContent,

packages/formik/test/Formik.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from 'react';
22
import { render, fireEvent, wait } from 'react-testing-library';
3-
import { FormikContextType } from '../src/types';
43
import * as Yup from 'yup';
54

65
import {
@@ -51,7 +50,7 @@ function Form({
5150

5251
const InitialValues = { name: 'jared' };
5352

54-
function renderFormik<V = Values>(props?: Partial<FormikConfig<V>> & React.RefAttributes<FormikContextType<V>>) {
53+
function renderFormik<V = Values>(props?: Partial<FormikConfig<V>> & React.RefAttributes<FormikProps<V>>) {
5554
let injected: any;
5655
const { rerender, ...rest } = render(
5756
<Formik
@@ -1299,7 +1298,7 @@ describe('<Formik>', () => {
12991298
});
13001299

13011300
it('exposes formikbag with forwardRef', () => {
1302-
const ref = React.createRef<FormikContextType<Values>>();
1301+
const ref = React.createRef<FormikProps<Values>>();
13031302

13041303
const { getProps } = renderFormik({ ref });
13051304

0 commit comments

Comments
 (0)