diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dac39198fd..40ca6c517f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,7 +84,7 @@ In the root of `/src`, there are a few files which are used to initialize the re - Sets standard page layout, about modal, and root dialog modal. - **RootProvider.jsx** - Sets up all context providers. - - Initializes i18n. + - Initializes i18n and router ### Naming files diff --git a/__tests__/index.test.jsx b/__tests__/index.test.jsx index d7ce697841..cf8f051938 100644 --- a/__tests__/index.test.jsx +++ b/__tests__/index.test.jsx @@ -1,7 +1,13 @@ +import React from 'react'; import { mount } from 'enzyme'; +import { MemoryRouter } from 'react-router-dom'; import { main } from '../src/index'; -const render = template => mount(template); +const render = template => mount( + + {template} + +); describe('index.jsx', () => { test('index.jsx loads without issue', () => { diff --git a/src/RootProvider.jsx b/src/RootProvider.jsx index 7a868e63a3..1f334c3b4c 100644 --- a/src/RootProvider.jsx +++ b/src/RootProvider.jsx @@ -3,6 +3,10 @@ import { I18nProvider, } from '@lingui/react'; +import { + HashRouter +} from 'react-router-dom'; + import { NetworkProvider } from './contexts/Network'; import { RootDialogProvider } from './contexts/RootDialog'; import { ConfigProvider } from './contexts/Config'; @@ -25,18 +29,20 @@ class RootProvider extends Component { const language = getLanguage(navigator); return ( - - - - - {children} - - - - + + + + + + {children} + + + + + ); } } diff --git a/src/index.jsx b/src/index.jsx index 55747eb036..099ab7a584 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -1,7 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { - HashRouter, Route, Switch, Redirect @@ -54,199 +53,197 @@ export function main (render) { const el = document.getElementById('app'); return render( - - - - {({ i18n }) => ( - - - ( - - {({ custom_logo, custom_login_info }) => ( - - )} - - )} - /> - } /> - ( - ( - - {routeGroups - .reduce((allRoutes, { routes }) => allRoutes.concat(routes), []) - .map(({ component: PageComponent, path }) => ( - ( - - )} - /> - )) - .concat([ - - ])} - - )} - /> - )} - /> - - - )} - - - , el || document.createElement('div') + + + {({ i18n }) => ( + + + ( + + {({ custom_logo, custom_login_info }) => ( + + )} + + )} + /> + } /> + ( + ( + + {routeGroups + .reduce((allRoutes, { routes }) => allRoutes.concat(routes), []) + .map(({ component: PageComponent, path }) => ( + ( + + )} + /> + )) + .concat([ + + ])} + + )} + /> + )} + /> + + + )} + + , el || document.createElement('div') ); }