score:1

i have the same setup and it works fine.

i have my auth state change listener at the top of my router...

state = { user: null };

componentdidmount() {
   firebase.auth().onauthstatechanged(user => {
      if (user) {
        this.setstate({ user });
      } else {
        this.props.history.push('/login');
      }
   });
 }

in login.js i have a form that connects to a login function similar to yours...

login() {
    firebase
      .auth()
      .signinwithemailandpassword(this.state.email, this.state.password)
      .then(res => {
        this.props.history.push('/');
      })
      .catch(err => console.error(error));
  }

the only thing that i can think of you gave history.replace, try changing to history.push.

if that doesn't work is there any chance you can set up a https://codesandbox.io/ with a mcve and i'd be happy to debug it https://stackoverflow.com/help/mcve


Related Query

More Query from same tag