I need help )
return (
<ButtonWrapperStyled>
<input {...getInputProps()} />
<Button {...getRootProps()}>Загрузить</Button>
{files.map((file) => {//file maybe FileProps or File type
if (file) {// How can I check file type here?
return <div>{file.fileId}</div>
} else {
return <div>{file.fileId}</div>
}
})}
</ButtonWrapperStyled>
)
I typed array, it may be FileProps or File type.
How can I check it correctly in files.map?
I can’t resolve this issue
2
Answers
You need to use type guards Type Guards and Differentiating Types