File tree Expand file tree Collapse file tree 3 files changed +13
-24
lines changed Expand file tree Collapse file tree 3 files changed +13
-24
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
- import { Link as BaseLink } from 'react-router-dom'
2
+ import { Link as BaseLink , NavLink as BaseNavLink } from 'react-router-dom'
3
3
import PageContext from './PageContext'
4
4
5
5
function computeTo ( to , lang ) {
@@ -9,10 +9,18 @@ function computeTo(to, lang) {
9
9
return to
10
10
}
11
11
12
- export default function Link ( props ) {
13
- return (
12
+ function createLink ( Component ) {
13
+ return props => (
14
14
< PageContext . Consumer >
15
- { ( { lang } ) => < BaseLink { ...props } to = { computeTo ( props . to , lang ) } /> }
15
+ { pageContext => (
16
+ < Component
17
+ { ...props }
18
+ to = { computeTo ( props . to , pageContext ? pageContext . lang : null ) }
19
+ />
20
+ ) }
16
21
</ PageContext . Consumer >
17
22
)
18
23
}
24
+
25
+ export const Link = createLink ( BaseLink )
26
+ export const NavLink = createLink ( BaseNavLink )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 9
9
HashRouter ,
10
10
Router ,
11
11
} from 'react-router-dom'
12
- export { default as Link } from './client/Link'
13
- export { default as NavLink } from './client/NavLink'
12
+ export * from './client/Link'
You can’t perform that action at this time.
0 commit comments