Skip to content

Commit

Permalink
Revert "Change layout of generics in main Formik class (jaredpalmer#370
Browse files Browse the repository at this point in the history
…)"

This reverts commit 8126bd5.
  • Loading branch information
jaredpalmer committed Jan 29, 2018
1 parent 8126bd5 commit 6c51b70
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/formik.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ export type FormikProps<Values> = FormikState<Values> &
FormikHandlers &
FormikComputedProps<Values>;

export class Formik<ExtraProps = {}, Values = object> extends React.Component<
FormikConfig<Values> & ExtraProps,
FormikState<any>
> {
export class Formik<
Props extends FormikConfig<Values> = FormikConfig<Values>,
Values = object
> extends React.Component<Props, FormikState<any>> {
static defaultProps = {
validateOnChange: true,
validateOnBlur: true,
Expand Down Expand Up @@ -221,7 +221,7 @@ export class Formik<ExtraProps = {}, Values = object> extends React.Component<
? this.state.errors && Object.keys(this.state.errors).length === 0
: this.props.isInitialValid !== false &&
isFunction(this.props.isInitialValid)
? (this.props.isInitialValid as (props: this['props']) => boolean)(
? (this.props.isInitialValid as (props: Props) => boolean)(
this.props
)
: (this.props.isInitialValid as boolean),
Expand All @@ -245,7 +245,7 @@ export class Formik<ExtraProps = {}, Values = object> extends React.Component<
};
}

constructor(props: FormikConfig<Values> & ExtraProps) {
constructor(props: Props) {
super(props);
this.state = {
values: props.initialValues || ({} as any),
Expand All @@ -257,9 +257,7 @@ export class Formik<ExtraProps = {}, Values = object> extends React.Component<
this.initialValues = props.initialValues || ({} as any);
}

componentWillReceiveProps(
nextProps: Readonly<FormikConfig<Values> & ExtraProps>
) {
componentWillReceiveProps(nextProps: Props) {
// If the initialValues change, reset the form
if (
this.props.enableReinitialize &&
Expand Down Expand Up @@ -581,7 +579,7 @@ export class Formik<ExtraProps = {}, Values = object> extends React.Component<
isValid: dirty
? this.state.errors && Object.keys(this.state.errors).length === 0
: isInitialValid !== false && isFunction(isInitialValid)
? (isInitialValid as (props: this['props']) => boolean)(this.props)
? (isInitialValid as (props: Props) => boolean)(this.props)
: (isInitialValid as boolean),
handleBlur: this.handleBlur,
handleChange: this.handleChange,
Expand Down Expand Up @@ -624,11 +622,15 @@ function warnAboutMissingIdentifier({
handlerName: string;
}) {
console.error(
`Warning: \`${handlerName}\` has triggered and you forgot to pass an \`id\` or \`name\` attribute to your input:
`Warning: \`${
handlerName
}\` has triggered and you forgot to pass an \`id\` or \`name\` attribute to your input:
${htmlContent}
Formik cannot determine which value to update. For more info see https://github.com/jaredpalmer/formik#${documentationAnchorLink}
Formik cannot determine which value to update. For more info see https://github.com/jaredpalmer/formik#${
documentationAnchorLink
}
`
);
}
Expand Down

0 comments on commit 6c51b70

Please sign in to comment.