Skip to content

Commit 77596db

Browse files
committed
Added RouterLink component for href creation in SPA application
1 parent d52011f commit 77596db

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/helloWorld.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { createApp,
2-
hString,
32
hElement,
43
hFragment
54
} from 'https://unpkg.com/tiny-react-lib@1.0.1/dist/index.js'

src/routing/route-authorization.js

Whitespace-only changes.

src/routing/router-component.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { defineComponent } from '../components/component'
2+
import { hElement, hSlot } from '../h'
3+
4+
export const RouterLink = defineComponent({
5+
render() {
6+
const { to } = this.props
7+
8+
return hElement('a', {
9+
href: to,
10+
on: { click: (e) => {
11+
e.preventDefault();
12+
this.appContext.router.navigateTo(to)
13+
}
14+
},
15+
},
16+
[hSlot()])
17+
}
18+
})

0 commit comments

Comments
 (0)