Ginger Bread
Ginger Bread

Reputation: 625

Cannot instantiate GetFormErrorInterface because GetFormErrorInterface [1] is not a polymorphic type

My code works fine, but I get this flow error when try to get redux form error from state:

Cannot instantiate GetFormErrorInterface because GetFormErrorInterface [1] is not a polymorphic type.

 node_modules/redux-form/lib/index.js.flow
 134│
 135│ declare export function getFormError(
 136│   getFormState: ?GetFormState
 137│ ): GetFormErrorInterface<*>
 138│
 139│ declare export function getFormNames(
 140│   getFormState: ?GetFormState

      node_modules/redux-form/lib/selectors/getFormError.types.js.flow
      [1]   2│ export type GetFormErrorInterface = (state: any) => any

Here is my code:

import { connect } from 'react-redux';
import { getFormError } from 'redux-form';
import { COMPACT_FORM_NAME } from '../data-layer/reviews/constants';
import {
    checkReviewQualityAsync,
    createReviewCompactAsync
} from '../data-layer/reviews/actions'; 


const enhance = compose(
   withRouter,
     connect(
     (state: RootState) => ({
       submitError: getFormError(COMPACT_FORM_NAME)(state),// << Here is the problem  
      }),
      {
       onCreateReview: createReviewCompactAsync,
       onCheckReviewQuality: checkReviewQualityAsync
      }
     )
 ); 

It seems that it will be easy to fix but I don't understand what is wrong and why I can't use GetFormError directly???? Please any help. Thank you in advance

Upvotes: 0

Views: 83

Answers (1)

Related Questions