Undefined is not an object RNFileSelector.Show
Hi,
I have installed the library using "npm install react-native-file-selector --save"
In android/app/build.gradle I have added the below lines
repositories { maven { url "http://dl.bintray.com/lukaville/maven" } maven { url "https://maven.google.com" } } allprojects { repositories { mavenLocal() jcenter() maven { url "https://maven.google.com" } } }
I have imported import RNFileSelector from 'react-native-file-selector'; in js file
on click of button calling
RNFileSelector.Show( { title: 'Select File', onDone: (path) => { console.log('file selected: ' + path) }, onCancel: () => { console.log('cancelled') } } );
I am getting "undefined is not an object RNFileSeector.Show"
Am I doing anything wrong?
Thanks @GunaSekhar1 for raising the issue.
Looks like the library is not linked properly. Can you please try below installation steps:
-
react-native link react-native-file-selector -
Add below snippet in your app build.gradle file
repositories {
maven {
url "http://dl.bintray.com/lukaville/maven"
}
maven { url "https://maven.google.com" }
...
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven { url "https://maven.google.com" }
...
}
}
- Add below color attributes in your app res/color.xml. You can provide your own color codes
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
Thanks </ Pranav >
i am getting the same in IOS and i have done all the linking options. help me.
i am getting the same in IOS and i have done all the linking options.
I fixed it by adding this:
Add implementation project(':react-native-file-selector') to dependencies block of yourfolder/android/app/build.gradle.
Add this code to yourfolder/android/app/src/main/java/com/<your-company>/<app-name>/MainApplication.java
import ui.fileselector.RNFileSelectorPackage;
....
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
........
new RNFileSelectorPackage()
);
}
Add this to yourfolder/android/settings.gradle
include ':react-native-file-selector'
project(':react-native-file-selector').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-file-selector/android')
Somehow this code is not get populated during linking (react-native link react-native-file-selector)
i am getting the same in IOS and i have done all the linking options. help me.