Skip to content

Commit

Permalink
closes #142
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Mar 1, 2020
1 parent 2d79b59 commit d4b83d0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ The `<route>` component provides the `route` property to its children (it's simp
</route>
```

Each `<route>` component has its own lifecycle attributes in order to let you know when it gets mounted or unmounted.

```riot
<app>
<router>
<route path="/home"
on-before-mount={onBeforeHomeMount}
on-mounted={onHomeMounted}
on-before-unmount={onBeforeHomeUnmount}
on-unmounted={onHomeUnmounted}
/>
</router>
</app>
```

### Standalone

This module was not only designed to be used with Riot.js but also as standalone module.
Expand Down
2 changes: 1 addition & 1 deletion src/components/route-hoc.riot
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
this.stream = route(props.path, props).on.value(this.onRoute)
},
onBeforeRoute(path, pathToRegexp) {
if (!match(path, this.state.pathToRegexp)) {
if (this.state.route && !match(path, this.state.pathToRegexp)) {
this.callLifecycleProperty('onBeforeUnmount', route)
this.update({
route: null
Expand Down

0 comments on commit d4b83d0

Please sign in to comment.