From 289091cec74a44689cddea0e6a2d412eb9083693 Mon Sep 17 00:00:00 2001 From: Tyler Graf Date: Tue, 7 May 2019 15:18:24 -0600 Subject: [PATCH 1/3] Utilize new Root component that includes ErrorBoundary and new useUser without context. --- .../scripts/utils/frontierInit.js | 2 +- packages/react-scripts/template/src/index.js | 21 +++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/packages/react-scripts/scripts/utils/frontierInit.js b/packages/react-scripts/scripts/utils/frontierInit.js index 876e4385d86..51b6df4409b 100644 --- a/packages/react-scripts/scripts/utils/frontierInit.js +++ b/packages/react-scripts/scripts/utils/frontierInit.js @@ -60,7 +60,7 @@ function installFrontierDependencies(appPath, appName, answers, ownPath) { '@fs/zion-user', '@fs/zion-router', '@fs/zion-subnav', - '@fs/zion-error-boundary', + '@fs/zion-root', '@fs/zion-style-normalize', 'http-proxy-middleware@0.19', '@emotion/core@10', diff --git a/packages/react-scripts/template/src/index.js b/packages/react-scripts/template/src/index.js index 11d1e44f253..30fcfb151f8 100644 --- a/packages/react-scripts/template/src/index.js +++ b/packages/react-scripts/template/src/index.js @@ -1,8 +1,7 @@ import React, { Suspense } from 'react' import ReactDOM from 'react-dom' -import { UserProvider } from '@fs/zion-user' -import RootErrorBoundary from '@fs/zion-error-boundary' -import { I18nProvider, addTranslations } from '@fs/zion-locale' +import Root from '@fs/zion-root' +import { addTranslations } from '@fs/zion-locale' import { Router, NotFound } from '@fs/zion-router' import App from './components/App' import * as serviceWorker from './serviceWorker' @@ -13,18 +12,14 @@ addTranslations(translations) const base = window.SERVER_DATA ? new URL(window.SERVER_DATA.appPath).pathname : '' const FrontierRoot = () => ( - + - - - - - - - - + + + + - + ) ReactDOM.render(, document.getElementById('root')) From 875ae1e3aa4956c3847d21a151b580dffccac43f Mon Sep 17 00:00:00 2001 From: Tyler Graf Date: Tue, 7 May 2019 15:24:20 -0600 Subject: [PATCH 2/3] Move default Suspense into Root. --- packages/react-scripts/template/src/index.js | 38 ++++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/react-scripts/template/src/index.js b/packages/react-scripts/template/src/index.js index 30fcfb151f8..64120df9c63 100644 --- a/packages/react-scripts/template/src/index.js +++ b/packages/react-scripts/template/src/index.js @@ -1,30 +1,30 @@ -import React, { Suspense } from 'react' -import ReactDOM from 'react-dom' -import Root from '@fs/zion-root' -import { addTranslations } from '@fs/zion-locale' -import { Router, NotFound } from '@fs/zion-router' -import App from './components/App' -import * as serviceWorker from './serviceWorker' -import translations from './locales' +import React from 'react'; +import ReactDOM from 'react-dom'; +import Root from '@fs/zion-root'; +import { addTranslations } from '@fs/zion-locale'; +import { Router, NotFound } from '@fs/zion-router'; +import App from './components/App'; +import * as serviceWorker from './serviceWorker'; +import translations from './locales'; -addTranslations(translations) +addTranslations(translations); -const base = window.SERVER_DATA ? new URL(window.SERVER_DATA.appPath).pathname : '' +const base = window.SERVER_DATA + ? new URL(window.SERVER_DATA.appPath).pathname + : ''; const FrontierRoot = () => ( - - - - - - + + + + -) +); -ReactDOM.render(, document.getElementById('root')) +ReactDOM.render(, document.getElementById('root')); // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: https://bit.ly/CRA-PWA -serviceWorker.unregister() +serviceWorker.unregister(); From 78c9f0e4e8e873a0fb476739dad875a44397e16d Mon Sep 17 00:00:00 2001 From: Tyler Graf Date: Tue, 7 May 2019 15:27:32 -0600 Subject: [PATCH 3/3] Run through our eslint. --- packages/react-scripts/template/src/index.js | 28 +++++++++----------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/packages/react-scripts/template/src/index.js b/packages/react-scripts/template/src/index.js index 64120df9c63..89e59756ba0 100644 --- a/packages/react-scripts/template/src/index.js +++ b/packages/react-scripts/template/src/index.js @@ -1,17 +1,15 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import Root from '@fs/zion-root'; -import { addTranslations } from '@fs/zion-locale'; -import { Router, NotFound } from '@fs/zion-router'; -import App from './components/App'; -import * as serviceWorker from './serviceWorker'; -import translations from './locales'; +import React from 'react' +import ReactDOM from 'react-dom' +import Root from '@fs/zion-root' +import { addTranslations } from '@fs/zion-locale' +import { Router, NotFound } from '@fs/zion-router' +import App from './components/App' +import * as serviceWorker from './serviceWorker' +import translations from './locales' -addTranslations(translations); +addTranslations(translations) -const base = window.SERVER_DATA - ? new URL(window.SERVER_DATA.appPath).pathname - : ''; +const base = window.SERVER_DATA ? new URL(window.SERVER_DATA.appPath).pathname : '' const FrontierRoot = () => ( @@ -20,11 +18,11 @@ const FrontierRoot = () => ( -); +) -ReactDOM.render(, document.getElementById('root')); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: https://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister()