From 7b8a39772b8472ce2fda0f2dbf5a2bd64523f9b7 Mon Sep 17 00:00:00 2001 From: Subroto Date: Mon, 28 Jan 2019 16:43:45 +0530 Subject: [PATCH] Fix `fileIndex` not found TypeError (IE 11) fileIndex is not present in IE 11 Array.prototype --- components/upload/Upload.tsx | 3 ++- typings/custom-typings.d.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/components/upload/Upload.tsx b/components/upload/Upload.tsx index dd6349af16..2c36b665ce 100644 --- a/components/upload/Upload.tsx +++ b/components/upload/Upload.tsx @@ -3,6 +3,7 @@ import { polyfill } from 'react-lifecycles-compat'; import RcUpload from 'rc-upload'; import classNames from 'classnames'; import uniqBy from 'lodash/uniqBy'; +import findIndex from 'lodash/findIndex'; import Dragger from './Dragger'; import UploadList from './UploadList'; import { @@ -73,7 +74,7 @@ class Upload extends React.Component { const nextFileList = this.state.fileList.concat(); - const fileIndex = nextFileList.findIndex(({ uid }) => uid === targetItem.uid); + const fileIndex = findIndex(nextFileList, ({ uid }: UploadFile) => uid === targetItem.uid); if (fileIndex === -1) { nextFileList.push(targetItem); } else { diff --git a/typings/custom-typings.d.ts b/typings/custom-typings.d.ts index 6d5fcdecb3..0f7caa0028 100644 --- a/typings/custom-typings.d.ts +++ b/typings/custom-typings.d.ts @@ -97,7 +97,9 @@ declare module 'lodash/padEnd'; declare module 'lodash/uniqBy'; -declare module "raf"; +declare module 'lodash/findIndex'; + +declare module 'raf'; declare module 'react-lifecycles-compat';