Created
October 1, 2021 16:17
-
-
Save naydav/c6b7f68953d2523782ff9ddb500058ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* <license header> | |
*/ | |
import React from 'react' | |
import { Provider, defaultTheme, View } from '@adobe/react-spectrum' | |
import ErrorBoundary from 'react-error-boundary' | |
import { HashRouter as Router } from 'react-router-dom' | |
import ActionsForm from './ActionsForm' | |
function App (props) { | |
console.log('runtime object:', props.runtime) | |
console.log('ims object:', props.ims) | |
// use exc runtime event handlers | |
// respond to configuration change events (e.g. user switches org) | |
props.runtime.on('configuration', ({ imsOrg, imsToken, locale }) => { | |
console.log('configuration change', { imsOrg, imsToken, locale }) | |
}) | |
// respond to history change events | |
props.runtime.on('history', ({ type, path }) => { | |
console.log('history change', { type, path }) | |
}) | |
return ( | |
<ErrorBoundary onError={onError} FallbackComponent={fallbackComponent}> | |
<Router> | |
<Provider theme={defaultTheme} colorScheme={`light`}> | |
<View gridArea='content' padding='size-200'> | |
<ActionsForm runtime={props.runtime} ims={props.ims} /> | |
</View> | |
</Provider> | |
</Router> | |
</ErrorBoundary> | |
) | |
// Methods | |
// error handler on UI rendering failure | |
function onError (e, componentStack) { } | |
// component to show if UI fails rendering | |
function fallbackComponent ({ componentStack, error }) { | |
return ( | |
<React.Fragment> | |
<h1 style={{ textAlign: 'center', marginTop: '20px' }}> | |
Something went wrong :( | |
</h1> | |
<pre>{componentStack + '\n' + error.message}</pre> | |
</React.Fragment> | |
) | |
} | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment