react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

RNFS blocked UI thread

Open aluksidadi opened this issue 10 years ago • 1 comments

Im experiencing weird behaviour where at some section of the code, RNFS works fine, but another section it blocked the UI thread. e.g.: unlink didnt product successCallback or errorCallback, or exists just blocked the code completely.

here's the snippet of the code:

        toSave.forEach((row) => {
            var p = new Promise((resolve, reject) => {
                    var fn = row.ContentDocumentId + getFileExtension(row.FileType);
                    var path = RNFS.DocumentDirectoryPath + '/' + fn;
                    sendRequest('/services/apexrest/ContentDoc', '/' + row.ContentDocumentId, (resp) => {
                        RNFS.writeFile(path, resp.base64, 'base64')
                          .then((success) => {
                            resolve();
                          })
                          .catch((err) => {
                            reject();
                          });
                    }, (err) => {
                        reject();
                    });
            });

            fileSavePromises.push(p);
        });

        Promise.all(fileSavePromises).then(() => {
            console.log('_saveAllFilesLocally -> done');
            successCallback();
        });

after that RNFS.DocumentDirectoryPath anything afterwards didnt get executed

Thanks

aluksidadi avatar Oct 29 '16 17:10 aluksidadi

dont mind this, i reinstall RNFS and it worked =)

aluksidadi avatar Oct 29 '16 17:10 aluksidadi