Skip to content

Pathname Environment, History API and a double click in the back button to go back? #194

@SofiaGR

Description

@SofiaGR

I apologize if this isn't the correct place to ask my question, but I can't seem to figure this out.

I'm currently using version 0.32.2 of the react-router-component and I'm having difficulties with using the History API along with the react-router-component.

I know I'm using the PathnameEnvironment as the default environment since I didn't set hash as true in the Locations, as shown below:

 onBeforeNavigation() {
    var stateObj = { title: '', url: window.location.pathname };
    this.state = stateObj;
    console.log('stateObj pushed: ', stateObj);
    //window.history.pushState(stateObj, stateObj.title, stateObj.url);
  },
onNavigation() {
    console.log('onNavigation: ', this.state);
    window.history.pushState(this.state, this.state.title, this.state.url);
  },
 <Locations onBeforeNavigation={this.onBeforeNavigation} onNavigation={this.onNavigation}>
        <Location path={'/'} handler={Bootstrap} component="Login"/>
        <Location path={'/demo'} handler={Bootstrap} component="Demo"/>
        <Location path={'/test'} handler={Test}/>
 </Locations>

I was looking at one of the tests for PathEnvironment, and tried to somewhat mimic its behavior, but while the react-router-component detects a popstate event, the path isn't changing (I confirmed it by placing a console.log in the popstate listener of PathnameEnvironment)...it only changes if I click twice in the back button. I can also see that whenever I navigate, only one entry is added to the browser's back history button. Am I doing anything wrong or missing anything? :/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions