Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
centralize loading app names
Browse files Browse the repository at this point in the history
  • Loading branch information
eh-am committed Apr 14, 2023
1 parent 1c5b2c8 commit 68e504e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
23 changes: 13 additions & 10 deletions public/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@ import history from '@webapp/util/history';

import { SingleView } from './pages/SingleView';
import { ComparisonView } from './pages/ComparisonView';
import { LoadAppNames } from './components/LoadAppNames';

const container = document.getElementById('reactRoot') as HTMLElement;
const root = ReactDOM.createRoot(container);

root.render(
<Provider store={store}>
<Notifications />
<Router history={history}>
<Switch>
<Route exact path={'/'}>
<SingleView />
</Route>
<Route path={'/comparison'}>
<ComparisonView />
</Route>
</Switch>
</Router>
<LoadAppNames>
<Router history={history}>
<Switch>
<Route exact path={'/'}>
<SingleView />
</Route>
<Route path={'/comparison'}>
<ComparisonView />
</Route>
</Switch>
</Router>
</LoadAppNames>
</Provider>
);
8 changes: 8 additions & 0 deletions public/app/components/LoadAppNames.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { loadAppNames } from '../hooks/loadAppNames';

// LoadAppNames loads all app names automatically
export function LoadAppNames(props: { children?: React.ReactNode }) {
loadAppNames();

return <>{props.children}</>;
}
3 changes: 0 additions & 3 deletions public/app/pages/ComparisonView.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import ContinuousComparisonView from '@webapp/pages/ContinuousComparisonView';
import { loadAppNames } from '../hooks/loadAppNames';

export function ComparisonView() {
loadAppNames();

return <ContinuousComparisonView />;
}
3 changes: 0 additions & 3 deletions public/app/pages/SingleView.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import ContinuousSingleView from '@webapp/pages/ContinuousSingleView';
import { loadAppNames } from '../hooks/loadAppNames';

export function SingleView() {
loadAppNames();

return <ContinuousSingleView />;
}

0 comments on commit 68e504e

Please sign in to comment.