https://github.com/shy2850/ipreact-router
ipreact-router
https://github.com/shy2850/ipreact-router
Last synced: 3 months ago
JSON representation
ipreact-router
- Host: GitHub
- URL: https://github.com/shy2850/ipreact-router
- Owner: shy2850
- License: apache-2.0
- Created: 2018-12-22T06:38:10.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-23T09:52:05.000Z (over 4 years ago)
- Last Synced: 2025-02-27T04:51:08.060Z (3 months ago)
- Language: TypeScript
- Homepage: https://shy2850.github.io/ipreact-router/index.html
- Size: 57.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ipreact-router
ipreact-router### usage
`npm i ipreact-router`
```tsx
import { h, Component, render } from 'preact'
import { Router, Route, Link } from './ipreact-router'
import { createHashHistory } from 'history'interface Com2Props {params: {title: string}}
class App extends Component {
com1 = () =>com1
com2 = ({params}: Com2Props) =>com2: {params.title}
com3 = () =>com3
com404 = () =>404
history = createHashHistory()
state = {pathname: this.history.location.pathname}
componentDidMount () {
const t = this;
t.history.listen((location) => {
t.setState({
pathname: location.pathname
})
})
}
render () {
const { pathname } = this.state
return
com1
com2
com2/heheda
com3
com3/sub
}
}render(, document.getElementById('app'))
```