I've got Cannot read property 'RNFSFileTypeRegular' of undefined after running app on ios, I'm using type script and also I follow the README file For RN >= 0.57 and/or Gradle >= 3 you MUST install react-native-fs at version @2.13.2!, here is my code:
constructor(props) {
super(props);
RNFS.readDir(RNFS.MainBundlePath) // On Android, use "RNFS.DocumentDirectoryPath" (MainBundlePath is not defined)
.then((result) => {
console.log('GOT RESULT', result);
// stat the first file
return Promise.all([RNFS.stat(result[0].path), result[0].path]);
})
.then((statResult) => {
if (statResult[0].isFile()) {
// if we have a file, read it
return RNFS.readFile(statResult[1], 'utf8');
}
return 'no file';
})
.then((contents) => {
// log the file contents
console.log(contents);
})
.catch((err) => {
console.log(err.message, err.code);
});
this.state = {};
}
I have the same issue when run in android device using 'expo start',
could you solved the problem?
thanks in advance
I'm experiencing this building a new [email protected] app from scratch and including the react-native-fs module.
NOTE: this only affects a new app on iOS (Android works fine)
UPDATE: I was able to fix this issue by adding pod 'RNFS', :path => '../node_modules/react-native-fs' to a new project's Podfile which is in the instructions for linking manually with Pods. It seems the auto-linking feature in [email protected] doesn't succeed for iOS.
For me I had to delete Podfile.lock file AND Pods dir, then the issue was resolved.
I am facing same issue in android. Any help?
The following two commands fixed it for me:
react-native unlink react-native-fs
react-native link react-native-fs
Most helpful comment
I am facing same issue in android. Any help?