Skip to content

Commit 1cb7cb3

Browse files
Merge pull request #169 from wednesday-solutions/feat/removing-formatjs-as-entrypoint
feat: removing formatjs as an entrypoint
2 parents 4758fe4 + 803e03d commit 1cb7cb3

File tree

3 files changed

+48
-50
lines changed

3 files changed

+48
-50
lines changed

app/app.js

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ import 'sanitize.css/sanitize.css';
1919
import App from 'containers/App/Loadable';
2020

2121
// Import Language Provider
22-
import LanguageProvider from 'containers/LanguageProvider';
2322
import ScrollToTop from 'components/ScrollToTop';
24-
import ErrorBoundary from '@components/ErrorBoundary';
2523
// Load the favicon and the .htaccess file
2624
/* eslint-disable import/no-unresolved, import/extensions */
2725
import '!file-loader?name=[name].[ext]!./images/favicon.ico';
@@ -30,9 +28,6 @@ import 'file-loader?name=.htaccess!./.htaccess';
3028

3129
import configureStore from './configureStore';
3230

33-
// Import i18n messages
34-
import { translationMessages } from './i18n';
35-
3631
// Create redux store with history
3732
const initialState = {};
3833
const { store, persistor } = configureStore(initialState, history);
@@ -41,19 +36,15 @@ const root = createRoot(container);
4136
const render = (messages) => {
4237
root.render(
4338
<StrictMode>
44-
<ErrorBoundary>
45-
<Provider store={store}>
46-
<PersistGate loading={null} persistor={persistor}>
47-
<LanguageProvider messages={messages}>
48-
<Router history={history}>
49-
<ScrollToTop>
50-
<App />
51-
</ScrollToTop>
52-
</Router>
53-
</LanguageProvider>
54-
</PersistGate>
55-
</Provider>
56-
</ErrorBoundary>
39+
<Provider store={store}>
40+
<PersistGate loading={null} persistor={persistor}>
41+
<Router history={history}>
42+
<ScrollToTop>
43+
<App />
44+
</ScrollToTop>
45+
</Router>
46+
</PersistGate>
47+
</Provider>
5748
</StrictMode>
5849
);
5950
};
@@ -63,20 +54,20 @@ if (module.hot) {
6354
// modules.hot.accept does not accept dynamic dependencies,
6455
// have to be constants at compile-time
6556
module.hot.accept(['./i18n', 'containers/App'], () => {
66-
render(translationMessages);
57+
render();
6758
});
6859
}
6960

7061
// Chunked polyfill for browsers without Intl support
7162
if (!window.Intl) {
7263
Promise.resolve(import('intl'))
7364
.then(() => Promise.all([import('intl/locale-data/jsonp/en.js')]))
74-
.then(() => render(translationMessages))
65+
.then(() => render())
7566
.catch((err) => {
7667
throw err;
7768
});
7869
} else {
79-
render(translationMessages);
70+
render();
8071
}
8172

8273
// Install ServiceWorker and AppCache in the end since

app/containers/App/index.js

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import GlobalStyle from '@app/global-styles';
2020
import { colors } from '@themes';
2121
import Header from '@components/Header';
2222
import For from '@components/For';
23+
import LanguageProvider from 'containers/LanguageProvider';
24+
import ErrorBoundary from '@app/components/ErrorBoundary/index';
25+
import { translationMessages } from '@app/i18n';
2326

2427
const theme = {
2528
fg: colors.primary,
@@ -35,33 +38,37 @@ export function App({ location, history }) {
3538
}, []);
3639

3740
return (
38-
<ThemeProvider theme={theme}>
39-
<Header />
40-
<Layout.Content>
41-
<For
42-
ParentComponent={(props) => <Switch {...props} />}
43-
of={map(Object.keys(routeConfig))}
44-
renderItem={(routeKey, index) => {
45-
const Component = routeConfig[routeKey].component;
46-
return (
47-
<Route
48-
exact={routeConfig[routeKey].exact}
49-
key={index}
50-
path={routeConfig[routeKey].route}
51-
render={(props) => {
52-
const updatedProps = {
53-
...props,
54-
...routeConfig[routeKey].props
55-
};
56-
return <Component {...updatedProps} />;
57-
}}
58-
/>
59-
);
60-
}}
61-
/>
62-
<GlobalStyle />
63-
</Layout.Content>
64-
</ThemeProvider>
41+
<ErrorBoundary>
42+
<LanguageProvider messages={translationMessages}>
43+
<ThemeProvider theme={theme}>
44+
<Header />
45+
<Layout.Content>
46+
<For
47+
ParentComponent={(props) => <Switch {...props} />}
48+
of={map(Object.keys(routeConfig))}
49+
renderItem={(routeKey, index) => {
50+
const Component = routeConfig[routeKey].component;
51+
return (
52+
<Route
53+
exact={routeConfig[routeKey].exact}
54+
key={index}
55+
path={routeConfig[routeKey].route}
56+
render={(props) => {
57+
const updatedProps = {
58+
...props,
59+
...routeConfig[routeKey].props
60+
};
61+
return <Component {...updatedProps} />;
62+
}}
63+
/>
64+
);
65+
}}
66+
/>
67+
<GlobalStyle />
68+
</Layout.Content>
69+
</ThemeProvider>
70+
</LanguageProvider>
71+
</ErrorBoundary>
6572
);
6673
}
6774
App.propTypes = {

app/containers/App/tests/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from 'react';
2-
import { renderProvider, renderWithIntl } from '@utils/testUtils';
2+
import { renderProvider } from '@utils/testUtils';
33
import App from '../index';
44
import { BrowserRouter } from 'react-router-dom';
55
import history from '@app/utils/history';
66
import { waitFor } from '@testing-library/react';
77

88
describe('<App /> container tests', () => {
99
it('should render and match the snapshot', () => {
10-
const { container } = renderWithIntl(
10+
const { container } = renderProvider(
1111
<BrowserRouter>
1212
<App />
1313
</BrowserRouter>

0 commit comments

Comments
 (0)