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

Component realoading when changing uri #98

Open
stefanhuber opened this issue Jun 13, 2019 · 2 comments
Open

Component realoading when changing uri #98

stefanhuber opened this issue Jun 13, 2019 · 2 comments

Comments

@stefanhuber
Copy link

Resources:
Before submitting an issue, please consult our docs.

Stencil version: (run npm list @stencil/core from a terminal/cmd prompt and paste output below):

`-- @stencil/core@1.0.3

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://stencil-worldwide.slack.com

Current behavior:

<stencil-router>
  <stencil-route-switch>       
    <stencil-route url="/complaints/state/:state" component="app-complaint-list" />
  </stencil-route-switch>   
</stencil-router>

When chaning the route with a <stencil-route-link> the component is not reloading. e.g.:

<stencil-route-linkanchorRole="link" anchorClass="nav-link" activeClass="active" url="/complaints/state/open">...
<stencil-route-linkanchorRole="link" anchorClass="nav-link" activeClass="active" url="/complaints/state/closed">...

Clicking on the links doesn't reload the app-complaint-list.

Expected behavior:
An already loaded component should reload if the uri changes.

Steps to reproduce:
Code above

Related code:
Code above

Other information:
Code above

@blikblum
Copy link

Probably you need to declare a @Prop() match and inject router properties (https://github.com/ionic-team/stencil-router/wiki/Inject-history-into-a-deep-component) in app-complaint-list class

@starikcetin
Copy link

starikcetin commented Sep 2, 2020

Found a solution:

  @Prop() match: MatchResults;
  @Watch('match')
  matchWatchHandler(newValue, oldValue) {
    // refresh your state here
  }

When the parameter changes in the URL, the match prop also changes. So we can trigger a @Watch and refresh the component's state.

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

No branches or pull requests

3 participants