react-native-fs
react-native-fs copied to clipboard
RNFS blocked UI thread
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
dont mind this, i reinstall RNFS and it worked =)