stacks-archive / blockstack-app-generator

Blockstack app generator
MIT License
43 stars 28 forks source link

Clean url with replaceState #58

Closed njordhov closed 5 years ago

njordhov commented 5 years ago

After authentication, cleaning the browser location by setting window.location results in untimely refreshing of the page:

window.location = window.location.origin

Instead, the window location can be cleaned using:

window.history.replaceState({}, document.title, "/")

The current implementation still requires a refresh unless there are more substantial refactoring of the signin flow. Here is a suggested replacement for the offending componentWillMount implementations in App.js that also resolves issue #25 :

componentDidMount() {
    if (userSession.isSignInPending()) {
      userSession.handlePendingSignIn().then((userData) => {
        // window.location = window.location.origin;
        window.history.replaceState({}, document.title, "/")
        this.setState({ userData: userData})
      });
    }
  }
zone117x commented 5 years ago

Could you make a PR with this changes? Looks like something we would merge.