Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preact Router is not able to be extended #264

Open
studentIvan opened this issue Jan 27, 2018 · 0 comments · May be fixed by #265
Open

Preact Router is not able to be extended #264

studentIvan opened this issue Jan 27, 2018 · 0 comments · May be fixed by #265

Comments

@studentIvan
Copy link

In my case I have to modify the preact router, to make it supports my own functions/behaviour/etc.

I can't do it right now:

  1. initEventListeners will always be called
  2. I can't write my own route function
  3. I can't write my own setUrl function

example code demonstrating the problem

import PreactRouter from 'preact-router';

export default class ExtendedPreactRouter extends PreactRouter {
  constructor(props) {
    super(props); // can't do it without it
    if (props.history) {
      setCustomHistory(props.history); // original code will throw me the error
      // even if I have exported the customHistory variable
    }

    this.state = {
      url: props.url || getCurrentUrl(),
    };

    // initEventListeners(); by the way it will be called, even if commented
  }
}

@studentIvan studentIvan linked a pull request Jan 27, 2018 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant