无法实施(react-native-document-picker)

时间:2018-09-17 05:48:02

标签: reactjs react-native document picker

我已经遵循给定文档中的所有过程,但是在两个平台上我仍然遇到以下错误:

关注链接https://www.npmjs.com/package/react-native-document-picker

  

console.error:“未定义不是对象(正在评估   '_reactNativeDocumentPicker.DocumentPicker.show')“错误   index.delta?platform=android&dev=true&minify=false:57115:29附件   index.delta?platform=android&dev=true&minify=false:101355:24 onPress   index.delta?platform=android&dev=true&minify=false:101392:36   touchableHandlePress   index.delta?platform=android&dev=true&minify=false:42176:47   _performSideEffectsForTransition index.delta?platform=android&dev=true&minify=false:15001:36   _receiveSignal index.delta?platform=android&dev=true&minify=false:14930:46   touchableHandleResponderRelease   index.delta?platform=android&dev=true&minify=false:14815:26   invokeGuardedCallback   index.delta?platform=android&dev=true&minify=false:15268:21   invokeGuardedCallback   index.delta?platform=android&dev=true&minify=false:15337:40   invokeGuardedCallbackAndCatchFirstError   index.delta?platform=android&dev=true&minify=false:15340:54   executeDispatch   index.delta?platform=android&dev=true&minify=false:15498:64   executeDispatchesInOrder   index.delta?platform=android&dev=true&minify=false:15518:26   executeDispatchesAndRelease   index.delta?platform=android&dev=true&minify=false:15613:35   executeDispatchesAndReleaseTopLevel   index.delta?platform=android&dev=true&minify=false:15626:43   forEachAccurated   index.delta?platform=android&dev=true&minify=false:15603:22   runEventsInBatch   index.delta?platform=android&dev=true&minify=false:15714:29   runExtractedEventsInBatch   index.delta?platform=android&dev=true&minify=false:15723:25   index.delta?platform=android&dev=true&minify=false:16723:36   批处理更新$ 1   index.delta?platform=android&dev=true&minify=false:25008:20   批处理更新   index.delta?platform=android&dev=true&minify=false:16663:33   _receiveRootNodeIDEvent index.delta?platform=android&dev=true&minify=false:16722:23   receiveTouches   index.delta?platform=android&dev=true&minify=false:16752:34   __callFunction index.delta?platform=android&dev=true&minify=false:2593:49   index.delta?platform=android&dev=true&minify=false:2370:31 __guard   index.delta?platform=android&dev=true&minify=false:2546:15   callFunctionReturnFlushedQueue   index.delta?platform=android&dev=true&minify=false:2369:21

使用的代码:

import { DocumentPicker, DocumentPickerUtil } from 'react-native-document-picker';

// iPhone/Android
attachment = () => {
        DocumentPicker.show({
            filetype: [DocumentPickerUtil.allFiles()],
        }, (error, res) => {
            this.setState({ ImageLoad: true })
            console.log(res, 'res data');
            if (res && res.uri) {
                var formData = new FormData();
                formData.append('messagefile', { name: res.fileName, uri: res.uri, type: res.type });
                console.log("form data : ", formData);
                console.log("API Uplod file : ", LOCAL_URL + '/api/uploadChatFiles')
                fetch(LOCAL_URL + '/api/uploadChatFiles', {
                    method: 'POST',
                    headers: {
                        Accept: 'application/json',
                        'Content-Type': 'multipart/form-data',
                    },
                    body: formData,
                }).then((response) => response.json())
                    .then((responseJson) => {
                        this.setState({ ImageLoad: false });
                        console.log('responseJson file name: ', JSON.stringify(responseJson.data.fieldname));
                        console.log('responseJson : ', JSON.stringify(responseJson));
                        if (responseJson.code === 200) {
                            this.setState({ visibleModal: null })
                        }

                        let message = {
                            text: responseJson.data.originalname,
                            from: this.props.senderId,
                            to: this.props.reciverId,
                            isFile: "1"
                        }

                        let messageJson = {
                            message: message,
                            to: this.props.reciverId,
                        }
                        this.socket.emit('message', messageJson);
                        this._storeMessages(message);

                    })
            }
        });
}

0 个答案:

没有答案