main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
842 bytes
|
Line | |
---|
1 | import React from 'react';
|
---|
2 | var createRouter = function () {
|
---|
3 | var context = React.createContext({
|
---|
4 | route: '',
|
---|
5 | });
|
---|
6 | // not sure if this supposed to be unused, ignoring ts error for now
|
---|
7 | // @ts-ignore
|
---|
8 | var Router = function (props) {
|
---|
9 | var route = props.route, fullRoute = props.fullRoute, parent = props.parent, children = props.children;
|
---|
10 | if (process.env.NODE_ENV !== 'production') {
|
---|
11 | if (typeof route !== 'string') {
|
---|
12 | throw new TypeError('Router route must be a string.');
|
---|
13 | }
|
---|
14 | }
|
---|
15 | return React.createElement(context.Provider, {
|
---|
16 | value: {
|
---|
17 | fullRoute: fullRoute || route,
|
---|
18 | route: route,
|
---|
19 | parent: parent,
|
---|
20 | },
|
---|
21 | children: children,
|
---|
22 | });
|
---|
23 | };
|
---|
24 | };
|
---|
25 | export default createRouter;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.