Hi I am running my react-native app on my local machine with iOS simulator. I have followed all of the instructions in the ReadMe here. But when I call the code snippet, I get the error:
"Cannot read property "getAll" of undefined"
Sounds like you have an issue properly initializing the module. Please share code here.
I think this error is often caused by linking problems.
@morenoh149
var Contacts = require('react-native-contacts');
class ImportContactScreen extends React.Component {
_pressRow(){
Contacts.getAll((err, contacts) => {
if(err && err.type === 'permissionDenied'){
// x.x
} else {
console.log(contacts)
}
});
}
render() {
return (
<View
style={styles.container}>
<StatusBar barStyle="default" />
<View style={styles.header}>
<Text style={styles.h1}>{"Hi, " + {this.props.name}. + "Let's import your contacts:"}</Text>
</View>
<View style={[styles.section, styles.last]}>
<F8Button
style={styles.button}
onPress={() => this._pressRow()}
caption="Import"
/>
</View>
</View>
);
}
I had the same problem, double check you followed the installation instructions. Specially this problems is due to missing library on the build phases of the project. (step 3 on ios installation)
You also need to rebuild your project by running react-native run-android or run-ios.
Was a victim of this.
I still encounter this problem , I trid all the way above,but nothing works ,Anyone can help me ? tkx
well, i solved by follow:
I still encounter this problem , I trid all the way above,but nothing works ,Anyone can help me ? tkx
try like me ....
i have the same problem.i will try these ways
@challengerST let us know if it works
+1
I've revised the readme to be more clear. This is an installation issue.
I have to delete the ios folder and build again using react-native eject and then use the react-native link
interesting, I've abandoned react-native link, it never worked for me.
I do not know what the problem is but some dependence does not work other, other I need to add manual
I've heard react-native link will update podfile if you use that. That may be part of it.
I have not had a very good experience with podfile, if it is to use podfile I would rather add manual myself.
Most helpful comment
You also need to rebuild your project by running react-native run-android or run-ios.
Was a victim of this.