Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Johnrom/formik core 2 #3

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
"serve": "next start"
},
"dependencies": {
"format-string-by-pattern": "^1.2.1",
"formik": "^2.1.5",
"@formik/reducer-refs": "^3.0.0-core1",
"format-string-by-pattern": "^1.2.1",
"formik": "^3.0.0-next.7",
"next": "9.5.3",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"yup": "^0.29.3"
},
"devDependencies": {
"@types/node": "^14.14.6",
"@types/react": "^16.9.56",
"@types/react": "^16.9.55",
"@types/react-dom": "^16.9.9"
}
}
2 changes: 1 addition & 1 deletion app/pages/format.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function Example() {
<Field
name={mask.name}
type="text"
parse={formatString(mask.parse)}
parse={formatString(mask.parse) as any}
placeholder={mask.parse}
/>
</label>
Expand Down
4 changes: 2 additions & 2 deletions app/pages/perf500.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ const Input = (p: FieldHookConfig<string>) => {
);
};

const isRequired = (v) => {
const isRequired = (v: string) => {
return v && v.trim() !== "" ? undefined : "Required";
};

const array = new Array(500).fill(undefined);

const initialValues = array.reduce((prev, curr, idx) => {
const initialValues = array.reduce((prev, _curr, idx) => {
prev[`Input ${idx}`] = "";
return prev;
}, {});
Expand Down
8 changes: 4 additions & 4 deletions app/pages/perf500v3.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Formik, Form, useField, FieldHookConfig } from "formik";
import { Formik, Form, useField, FieldConfig } from "formik";

const Input = (p: FieldHookConfig<string>) => {
const Input = (p: FieldConfig<string>) => {
const [field, meta] = useField(p);
const renders = React.useRef(0);
return (
Expand All @@ -19,13 +19,13 @@ const Input = (p: FieldHookConfig<string>) => {
);
};

const isRequired = (v) => {
const isRequired = (v: string) => {
return v && v.trim() !== "" ? undefined : "Required";
};

const array = new Array(500).fill(undefined);

const initialValues = array.reduce((prev, curr, idx) => {
const initialValues = array.reduce((prev, _curr, idx) => {
prev[`Input ${idx}`] = "";
return prev;
}, {});
Expand Down
4 changes: 2 additions & 2 deletions app/pages/v3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ export default function Example() {
<CustomFieldOld
name={mask.name}
type="text"
parse={formatString(mask.parse)}
parse={formatString(mask.parse) as any}
placeholder={mask.parse}
/>
) : (
<CustomFieldNew
name={mask.name}
type="text"
parse={formatString(mask.parse)}
parse={formatString(mask.parse) as any}
placeholder={mask.parse}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"sourceMap": true,
Expand Down
8 changes: 4 additions & 4 deletions packages/@formik/reducer-refs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@
"use-context-selector": "^1.1.2"
},
"resolutions": {
"@types/react": "16.9.17",
"@types/react-dom": "16.9.4"
"@types/react": "^16.9.55",
"@types/react-dom": "^16.9.9"
},
"devDependencies": {
"@types/hoist-non-react-statics": "^3.3.1",
"@types/lodash": "^4.14.119",
"@types/react": "^16.9.17",
"@types/react-dom": "^16.9.4",
"@types/react": "^16.9.55",
"@types/react-dom": "^16.9.9",
"@types/warning": "^3.0.0",
"@types/yup": "^0.24.9",
"just-debounce-it": "^1.1.0",
Expand Down
208 changes: 0 additions & 208 deletions packages/@formik/reducer-refs/src/FastField.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { FormikContextType, getIn, isFunction } from '@formik/core';
import { connect } from './connect';
import { connect } from '../connect';

export interface ErrorMessageProps {
name: string;
Expand Down
37 changes: 37 additions & 0 deletions packages/@formik/reducer-refs/src/components/FastField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as React from 'react';
import {
GenericFieldHTMLAttributes,
FormikValues,
} from '@formik/core';
import { FieldConfig, FieldProps } from '../hooks/useField';
import { Field } from './Field';

/**
* @deprecated please use FieldProps (and Field or useField!)
*/
export type FastFieldProps<V> = FieldProps<V>;

/**
* @deprecated please use FieldConfig (and Field or useField!)
*/
export type FastFieldConfig<T> = FieldConfig & {
/** Override FastField's default shouldComponentUpdate */
shouldUpdate?: (
nextProps: T & GenericFieldHTMLAttributes,
props: {}
) => boolean;
};

/**
* @deprecated please use FieldAttributes (and Field or useField!)
*/
export type FastFieldAttributes<T> = GenericFieldHTMLAttributes &
FastFieldConfig<T> &
T;

/**
* @deprecated Please use Field! We promise it is fast now!
*/
export const FastField = <Value extends FormikValues>(
{ shouldUpdate, ...fieldProps }: FastFieldConfig<Value>
) => <Field {...fieldProps} />;
Loading