Skip to content

Commit 1fd3393

Browse files
committed
fix(core): fix router export
1 parent 9bca154 commit 1fd3393

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react'
2+
import { NavLink as BaseNavLink } from 'react-router-dom'
3+
import PageContext from './PageContext'
4+
5+
function computeTo(to, lang) {
6+
if (lang) {
7+
return `/${lang}${to}`
8+
}
9+
return to
10+
}
11+
12+
export default function NavLink(props) {
13+
return (
14+
<PageContext.Consumer>
15+
{({ lang }) => <BaseNavLink {...props} to={computeTo(props.to, lang)} />}
16+
</PageContext.Consumer>
17+
)
18+
}

packages/smooth-core/src/router.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1+
export {
2+
withRouter,
3+
matchPath,
4+
generatePath,
5+
Switch,
6+
Route,
7+
Redirect,
8+
} from 'react-router-dom'
19
export { default as Link } from './client/Link'
10+
export { default as NavLink } from './client/NavLink'

0 commit comments

Comments
 (0)