Reputation: 1785
Im calling a function (signUpUser) from a separate file as follows:
<MyButton
onPress={() =>
signUpUser(
this.state.userName,
this.state.email,
this.state.password,
)
}
>
in my separate file called firebase.js, the function is as follows:
export const signUpUser = (userName, email, password) => {
Firebase.auth()
.createUserWithEmailAndPassword(email, password)
.then((user) => {
Firebase.database()
.ref('profiles/users/' + user.user.uid)
.set({
.....etc
});
})
.catch(err => Alert.alert(err));
};
Im importing as follows:
import signUpUser from '../firebase';
Why an i getting an error ""(0, _firebase3.default) is not a function?
Thanks in advance
Upvotes: 0
Views: 162
Reputation: 327
You are exporting a named function. Change import statement to
import {signUpUser} from '../firebase';
Or if you want you can change the export statement to a default export
const signUpUser = (userName, email, password) => {
Firebase.auth()
.createUserWithEmailAndPassword(email, password)
.then((user) => {
Firebase.database()
.ref('profiles/users/' + user.user.uid)
.set({
.....etc
});
})
.catch(err => Alert.alert(err));
};
export default signUpUser;
Upvotes: 3