itinance / itinance/react-native-fs

Cannot read property 'RNFSFileTypeRegular' of undefined on typescript

Open
#703 5 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

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 = {};
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.