0

In the code below, the Register component is staying on the page after the route changes to "/" (via history.push("/")). However, if I subsequently refresh the page, it disappears and everything looks how it should. Any ideas why that is happening?

    <Router>
      <React.Fragment>
        <Route
          path="/register"
          exact
          render={() => <Register register={this.register} />}
        />
        <Route
          path="/"
          exact
          render={() => (
            <Main
              posts={posts}
              post={post}
              preview={preview}
            />
          )}
        />
      </React.Fragment>
    </Router>

Here is the register method responsible for pushing to the root route:

register = (e, credentials) => {
    e.preventDefault();
    if (authEmails.includes(credentials.email)) {
      rxcInit
        .auth()
        .createUserWithEmailAndPassword(credentials.email, credentials.password)
        .then(() => {
          history.push("/");
        })
        .catch(error => {
          var errorMessage = error.message;
          console.log(errorMessage);
          this.setState({ modalShowing: true, errorMsg: errorMessage });
        });
    } else {
      this.setState({
        modalShowing: true,
        errorMsg:
          "That email address isn't authorized."
      });
    }
  };
Matthew Masurka
  • 325
  • 3
  • 14

0 Answers0