Comments (5)
Is this router dead? I just tried to create a stencil application, and the template just leads to bugs and the code doesn't reflect how this router should work and I'm very confused. Can one even create applications with Stencil right now (using this router)?
from stencil-router.
I've ditched it and rolled my own, there is no evidence to suggest this repo is maintained.
from stencil-router.
In my app-root.tsx
file
@State() path: string = location.pathname;
componentWillLoad() {
addEventListener('locationChange', () => (this.path = location.pathname));
addEventListener('popstate', () => (this.path = location.pathname));
}
render() {
if (this.path === '/') return <home-page />;
if (this.path === '/login') return <login-page />;
return <page-not-found />;
}
In a utils.ts
file
export function navigate(path: string) {
history.pushState({}, '', path);
dispatchEvent(new Event('locationChange'));
}
In components that need to query location
if (location.pathname.includes('login')) { ... }
And for things like URL params I just use regex matching where needed.
It all seems to work quite well.
from stencil-router.
In my
app-root.tsx
file@State() path: string = location.pathname; componentWillLoad() { addEventListener('locationChange', () => (this.path = location.pathname)); addEventListener('popstate', () => (this.path = location.pathname)); } render() { if (this.path === '/') return <home-page />; if (this.path === '/login') return <login-page />; return <page-not-found />; }In a
utils.ts
fileexport function navigate(path: string) { history.pushState({}, '', path); dispatchEvent(new Event('locationChange')); }In components that need to query location
if (location.pathname.includes('login')) { ... }And for things like URL params I just use regex matching where needed.
It all seems to work quite well.
Thanks! It was very helpful.
from stencil-router.
Are there any alternative routers can be used in Stencil application?
from stencil-router.
Related Issues (20)
- Route transitons
- Can't style anchor link when used in shadow false, but scoped true HOT 1
- Incorrect match when multiple urlMatch attributes are defined as regular expressions
- Routing to same page with dynamic params HOT 2
- `stencil-route-redirect` named `stencil-router-redirect`
- Immutable prop warning for various components HOT 9
- [v2] Handle links clicks without calling href()
- Release v2 in this repo HOT 1
- test1
- test2
- test3
- test4
- App with stencil-router doesn't compile in Stencil 2.14+ because of TypeScript 4.5 HOT 5
- Bug: @Prop <prop_name> on <>is immutable on <stencil_router_component>
- Bug: Path parameter values will be converted to lowercase
- Stencil routes not working on deploy folder HOT 1
- Navigation: Improve .push() and introduce .replace() method
- Package Update HOT 1
- Module '"@stencil-community/router"' has no exported member 'createRouter'. HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stencil-router.