Source: App.js

  1. /**
  2. * Internal module, you should not use it directly
  3. * @module react-cmf/lib/App
  4. */
  5. import PropTypes from 'prop-types';
  6. import { Provider } from 'react-redux';
  7. import RegistryProvider from './RegistryProvider';
  8. import { WaitForSettings } from './settings';
  9. import ErrorBoundary from './components/ErrorBoundary/ErrorBoundary.component';
  10. /**
  11. * The React component that render your app and provide CMF environment.
  12. * @param {object} props { store }
  13. * @return {object} ReactElement
  14. */
  15. export default function App(props) {
  16. let content = props.children;
  17. if (props.withSettings) {
  18. content = <WaitForSettings loading={props.loading}>{content}</WaitForSettings>;
  19. }
  20. return (
  21. <Provider store={props.store}>
  22. <RegistryProvider value={props.registry}>
  23. <ErrorBoundary fullPage>{content}</ErrorBoundary>
  24. </RegistryProvider>
  25. </Provider>
  26. );
  27. }
  28. App.displayName = 'CMFApp';
  29. App.propTypes = {
  30. store: PropTypes.object.isRequired,
  31. registry: PropTypes.object,
  32. children: PropTypes.node,
  33. withSettings: PropTypes.bool,
  34. loading: PropTypes.func,
  35. };
  36. App.defaultProps = {
  37. loading: () => 'loading',
  38. };