From 924c2aefc077d9b99bc7e96624d413019d754799 Mon Sep 17 00:00:00 2001 From: chrisgarrity Date: Wed, 14 Feb 2018 15:10:56 -0500 Subject: [PATCH] Make Error Boundary into HOC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don’t translate IE error modal, if there are errors during the `connect` process the `IntlProvider` doesn’t get set up and the error modal can’t be shown. --- .../browser-modal/browser-modal.jsx | 42 +++++-------------- src/playground/error-boundary-hoc.jsx | 18 ++++++++ src/playground/index.jsx | 10 +---- 3 files changed, 31 insertions(+), 39 deletions(-) create mode 100644 src/playground/error-boundary-hoc.jsx diff --git a/src/components/browser-modal/browser-modal.jsx b/src/components/browser-modal/browser-modal.jsx index 9052d5f57..9c169bfaa 100644 --- a/src/components/browser-modal/browser-modal.jsx +++ b/src/components/browser-modal/browser-modal.jsx @@ -2,7 +2,6 @@ import PropTypes from 'prop-types'; import React from 'react'; import ReactModal from 'react-modal'; import Box from '../box/box.jsx'; -import {defineMessages, injectIntl, intlShape, FormattedMessage} from 'react-intl'; import styles from './browser-modal.css'; @@ -18,16 +17,14 @@ const BrowserModal = ({intl, ...props}) => ( -

- -

+

Internet Explorer is not supported

{ /* eslint-disable max-len */ } ( className={styles.backButton} onClick={props.onBack} > - + Back

- - - - ) - }} - /> + To learn more, go to the {' '} + + preview FAQ + .
); BrowserModal.propTypes = { - intl: intlShape.isRequired, onBack: PropTypes.func.isRequired }; -export default injectIntl(BrowserModal); +export default BrowserModal; diff --git a/src/playground/error-boundary-hoc.jsx b/src/playground/error-boundary-hoc.jsx new file mode 100644 index 000000000..913242985 --- /dev/null +++ b/src/playground/error-boundary-hoc.jsx @@ -0,0 +1,18 @@ +import React from 'react'; +import ErrorBoundary from '../containers/error-boundary.jsx'; + +/* + * Higher Order Component to provide error boundary for wrapped component + * @param {React.Component} WrappedComponent - component to provide state for + * @returns {React.Component} component with error boundary + */ +const ErrorBoundaryHOC = function (WrappedComponent) { + const ErrorBoundaryWrapper = props => ( + + + + ); + return ErrorBoundaryWrapper; +}; + +export default ErrorBoundaryHOC; diff --git a/src/playground/index.jsx b/src/playground/index.jsx index ffa023b96..d8a844ac3 100644 --- a/src/playground/index.jsx +++ b/src/playground/index.jsx @@ -6,7 +6,7 @@ import Modal from 'react-modal'; import analytics from '../lib/analytics'; import GUI from '../containers/gui.jsx'; import ProjectLoaderHOC from './project-loader-hoc.jsx'; -import ErrorBoundary from '../containers/error-boundary.jsx'; +import ErrorBoundaryHOC from './error-boundary-hoc.jsx'; import styles from './index.css'; @@ -18,13 +18,7 @@ if (process.env.NODE_ENV === 'production' && typeof window === 'object') { // Register "base" page view analytics.pageview('/'); -const ErrorWrappedGUI = props => ( - - - -); - -const App = ProjectLoaderHOC(ErrorWrappedGUI); +const App = ProjectLoaderHOC(ErrorBoundaryHOC(GUI)); const appTarget = document.createElement('div'); appTarget.className = styles.app;