У меня есть компонент ввода, который я включаю в компонент более крупной формы, и Flow выдает следующую ошибку.
Cannot instantiate React.Element because class UploaderInput [1] is incompatible with string [2] in type argument
ElementType.
src/components/provider/signout/SignoutNoteForm.jsx
108│ />
109│ </div>
110│ <div>
111│ <UploaderInput
112│ dropInstructions = "Drop files to attach to this signout or click to browse"
113│ error = {errors}
114│ files = {values.files}
115│ name = "files"
116│ onChange = {value => setFieldValue(`files`, value)}
117│ onUploadingStart = {startUploading}
118│ onUploadingComplete = {stopUploading}
119│ s3Url = {s3Url}
120│ title = "Upload Files"
121│ touched = {touched}
122│ uploadOptions = {uploadOptions}
123│ />
124│ <ErrorMessage message = {touched.files && errors.files ? errors.files : ''} />
125│ </div>
126│ <div>
/private/tmp/flow/flowlib_1e7d8b2/react.js
[2] 170│ | string
src/components/form/UploaderInput.jsx
[1] 98│ export default class UploaderInput extends Component<Props, State> {
Это не единственный мой входной компонент, и у меня нет проблем ни с одним из остальных. Что означает это довольно непрозрачное сообщение и как можно с ним справиться?





Оказывается, это было несоответствие между моим Props и моим defaultProps в типе UploaderInput.
Эта команда:
flow check --show-all-branches
сделал это намного понятнее и является хорошим советом для будущей отладки.
Cannot instantiate React.Element because in type argument ElementType:
• Either class UploaderInput [1] is incompatible with string [2].
• Or null [3] is incompatible with string [4].
components/provider/signout/SignoutNoteForm.jsx
108│ />
109│ </div>
110│ <div>
111│ <UploaderInput
112│ dropInstructions = "Drop files to attach to this signout or click to browse"
113│ error = {errors}
114│ files = {values.files}
115│ name = "files"
116│ onChange = {value => setFieldValue(`files`, value)}
117│ onUploadingStart = {startUploading}
118│ onUploadingComplete = {stopUploading}
119│ s3Url = {s3Url}
120│ title = "Upload Files"
121│ touched = {touched}
122│ uploadOptions = {uploadOptions}
123│ />
124│ <ErrorMessage message = {touched.files && errors.files ? errors.files : ''} />
125│ </div>
126│ <div>
/private/tmp/flow/flowlib_2ba42473/react.js
[2] 170│ | string
components/form/UploaderInput.jsx
[4] 81│ title: string,
:
[1] 98│ export default class UploaderInput extends Component<Props, State> {
:
[3] 107│ title: null,