Conditions | 3 |
Paths | 3 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | import React from 'react'; |
||
23 | render () { |
||
24 | const path = this.context.location.path; |
||
25 | let routeParams; |
||
26 | let fourOhFour; |
||
27 | const activeRoute = this.props.routes(path).filter((route) => { |
||
28 | if (route[0] === '*') { |
||
29 | fourOhFour = route; |
||
30 | return false; |
||
31 | } |
||
32 | const hasParams = route[0].match(':'); |
||
33 | if (hasParams) { |
||
34 | const { trueRoute, params } = getParams(route[0], path); |
||
35 | routeParams = params; |
||
36 | return trueRoute === path; |
||
37 | } |
||
38 | return route[0] === path; |
||
39 | }); |
||
40 | |||
41 | const props = JSON.parse(JSON.stringify(this.context)); |
||
42 | |||
43 | if (!activeRoute.length) { |
||
44 | return fourOhFour[1](props); |
||
45 | } |
||
46 | |||
47 | props.location.params = activeRoute[0][0].match(':') ? routeParams : {}; |
||
48 | return activeRoute[0][1](props); |
||
49 | } |
||
50 | } |
||
64 |