获取Edge Browser的浏览器特定错误-TypeError:对象不支持属性或方法“ get”

时间:2019-01-11 14:45:57

标签: javascript reactjs redux

我已经使用react.js和redux saga编写了一个代码来上传文件。单击上载按钮并将文件ID附加到FormData并传递给api调用时,将发生后端api调用。在google chrome和mozilla firefox中,一切正常,即文件上传。但是在Edge浏览器中却不起作用。该文件似乎已上传,但页面崩溃,直到重新加载该页面才起作用。

我在api调用中遇到以下错误。

SCRIPT5022: Objects are not valid as a React child (found: TypeError: Object doesn't support property or method 'get'). If you meant to render a collection of children, use an array instead.
    in span (created by MessageAlert)
    in div (created by MessageAlert)
    in MessageAlert (created by Connect(MessageAlert))
    in Connect(MessageAlert) (created by Routes)
    in Routes (created by Connect(Routes))
    in Connect(Routes) (created by App)
    in Provider (created by App)
    in App
    in AppContainer

上面的错误发生在组件中:

in span (created by MessageAlert)
in div (created by MessageAlert)
in MessageAlert (created by Connect(MessageAlert))
in Connect(MessageAlert) (created by Routes)
in Routes (created by Connect(Routes))
in Connect(Routes) (created by App)
in Provider (created by App)
in App
in AppContainer

React会尝试使用您提供的错误边界AppContainer从头开始重新创建此组件树。

,还有一些错误,例如无法获取未定义或空引用的属性“包含”。 在已卸载的组件上找不到节点。

如前所述,这仅在Edge浏览器中发生,也尝试过对其进行更新但不起作用。一切在chrome和mozilla中都可以正常运行。

请找到可能的错误原因的代码段。

    export function* fileUploadSaga(action) {
    const { payload } = action;
    if (payload) {
    const url = '/rest/files/upload';
    try {
    if (payload.data && payload.data.offset === 0)
    yield put(loaderEnable());
    const channel = yield call(uploadFileRequest, url, payload.data);
    while (true) {
    const { progress, err, success, response, xhr } = yield 
    take(channel);
    yield put(storeFileProgress({
    file: payload.data && payload.data.get('file'),
    fileSize: payload.data && payload.data.get('file')['size'],
    progress: progress || 100,
    fileName: payload.data && payload.data.get('file')['name'],
    xhr: xhr
    }));
    if (err) {
    yield put(showMessageAlert({
    message: 'Error uploading file!',
    visible: true,
    type: 'error',
    }));
    if (payload.data && payload.data.offset === 0)
    yield put(loaderDisable());
    return;
    }
    if (success && response) {
    yield put(storeFileProgress({
    file: payload.data && payload.data.get('file'),
    fileSize: payload.data && payload.data.get('file')['size'],
    progress: 100,
    fileName: payload.data && payload.data.get('file')['name'],
    xhr: xhr
    }));
    yield put(showMessageAlert({
    message: 'file uploaded successfully',
    visible: true,
    type: 'success',
    }));
    yield put(updateFiles({
    response: response && response.entity,
    isAdd: true,
    }));
    handleClick('File Manager', 'File Upload', 'File Upload');
    if (payload.data && payload.data.offset === 0)
    yield put(loaderDisable());
    }
    }

这是发生api调用的传奇代码。

    handleFileUpload = () => {
            const repoIdList = [];
            this.state.selectedRepo &&
            this.state.selectedRepo.forEach((repo) => {
                repoIdList.push(repo.id);
            });
            this.state.storeUploadedFiles &&
            this.state.storeUploadedFiles.forEach(file => {
                let data = new FormData();
                data.append('file', file);
                repoIdList && repoIdList.forEach(id => 
         data.append('id', id));
                // debugger

        this.props.dispatch(handleFileUploadInManager({data}));
            });
            // debugger
            this.props.closePopup();
        };

这是调用传奇的代码。...意味着api。

0 个答案:

没有答案