Skip to content

Overriding _handleBack in Router.App component #409

@jhomlala

Description

@jhomlala

Hi, I've found interesting issue. _handleBack is not getting called in component which extends Router.App.

export class App extends Router.App {
  static _template() {
    ...
  }

  _setup() {
    startRotuer(routes)
  }

  _handleBack() {
    //This will be never called
  }
}

I've looked into router code and I've found that this is caused by this line:

app._handleBack = e => {

Is this expected that router will override _handleBack? Shouldn't the app be able to decide whether it wants to navigate back or not?

In order to handle back navigation in our app component we had to fix it like this:

export class App extends Router.App {
  static _template() {
    ...
  }

  _setup() {
    startRotuer(routes)
    app._handleBack = function () {
      // Handle back here. Decide whether we should step back in navigation (pop) or do something else.
    }
  }

  _handleBack() {
    //This will be never called
  }
}

Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions