1

I got login form - SignIn.js:

<form onSubmit={this.onSubmit}>
    <div className="form-group">
        <label htmlFor="email">Email</label>
        <input type="text" className="form-control" name="email" value={this.state.email} onChange={this.onChange} />
    </div>
    <div className="form-group">
        <label htmlFor="password">Password</label>
        <input type="password" className="form-control" name="password" value={this.state.password} onChange={this.onChange} />
    </div>
    <input type="submit" value="Login" className="btn btn-primary btn-block" />
</form>
...  
export default firebaseConnect()(SignIn);

and onSubmit, where I want to login to Firebase/Firestore

 onSubmit = e => {
    e.preventDefault();

    const { firebase } = this.props;
    const { email, password } = this.state;

    firebase
      .login({email, password})
      .catch(err => alert('Invalid Login Credentials'));
  };

When I try to login i got this error:

TypeError: firebase.auth is not a function

I have tried also this:

firebase.auth().signInWithEmailAndPassword(email, password);

but I got the same issue.

My store:

const rootReducer = combineReducers({
  firebase: firebaseReducer,
  firestore: firestoreReducer});
const initialState = {};    
const store = createStore(
  rootReducer,
  initialState,
  window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());

const rrfProps = {
 firebase,
 config: {},
 dispatch: store.dispatch,
 createFirestoreInstance};

ReactDOM.render(
  <Provider store={store}>
    <ReactReduxFirebaseProvider {...rrfProps}>

      <App />

    </ReactReduxFirebaseProvider>
  </Provider>,
  document.getElementById("root")
);

firebaseConfig.js

const fc = {
//data from Firebase (apiKey, authDomain...)
}    
firebase.initializeApp(fc);
firebase.firestore();
export default firebase;
4est
  • 3,010
  • 6
  • 41
  • 63

1 Answers1

1

Based on firebase.auth is not a function I did as follow inside my firebaseConfig.js

import firebase from "firebase";
import "firebase/firestore";

albo this is working as well:

import firebase from "firebase/app";
import "firebase/firestore";
import "firebase/auth";
4est
  • 3,010
  • 6
  • 41
  • 63