stencil-community/stencil-router

Route Title does not update document's Title dynamically

natemoo-re opened this issue · 0 comments

Stencil version:

@stencil/starter@0.0.1 
└── @stencil/core@0.13.0
└── @stencil/router@0.3.0

I'm submitting a ...
[x] bug report
[ ] feature request
[ ] support request

Current behavior:
<stencil-route-title /> updates document.title only once, using the componentWillLoad hook. Dynamically updating pageTitle does not update document.title.

Expected behavior:
<stencil-route-title /> should update document.title to the current value of pageTitle whenever pageTitle is updated.

Related code:

// app-root.tsx
render() {
    return (
        <stencil-router>
            <stencil-route-switch>
                <stencil-route url='/demo/:name' component='demo-page' />
            </stencil-route-switch>
        </stencil-router>
    );
}
// demo-page.tsx
render() {
    return [
        <stencil-route-title pageTitle={`Hello ${this.match.params.name}!`}></stencil-route-title>,
        <h1> Hello {this.match.params.name}! </h1>
    ];
}

Other information:
I think it just needs to use Watch rather than componentWillLoad in route-title.tsx

Seems like an easy fix! I'm happy to make a PR.