From 9d24a74a024f5e80392fff84edb2ef47995b0ab1 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Thu, 19 Mar 2020 12:05:58 +0100 Subject: [PATCH] Pass handlers instead of elements --- docs/src/modules/components/Demo.js | 2 +- docs/src/modules/components/DemoErrorBoundary.js | 12 ++++++++---- docs/src/modules/components/DemoSandboxed.js | 13 +++---------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/docs/src/modules/components/Demo.js b/docs/src/modules/components/Demo.js index dc42093c577ec8..950111c6ed5e3e 100644 --- a/docs/src/modules/components/Demo.js +++ b/docs/src/modules/components/Demo.js @@ -361,7 +361,7 @@ function Demo(props) { component={DemoComponent} iframe={demoOptions.iframe} name={demoName} - resetDemo={resetDemo} + onResetDemoClick={resetDemo} />
diff --git a/docs/src/modules/components/DemoErrorBoundary.js b/docs/src/modules/components/DemoErrorBoundary.js index 24a2c62a50a64d..b37da64680bc4e 100644 --- a/docs/src/modules/components/DemoErrorBoundary.js +++ b/docs/src/modules/components/DemoErrorBoundary.js @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import Typography from '@material-ui/core/Typography'; import Link from '@material-ui/core/Link'; +import Button from '@material-ui/core/Button'; export default class DemoErrorBoundary extends React.Component { state = { @@ -13,7 +14,7 @@ export default class DemoErrorBoundary extends React.Component { } render() { - const { children, errorActions } = this.props; + const { children, onResetDemoClick, t } = this.props; const { error } = this.state; if (error) { @@ -34,7 +35,9 @@ export default class DemoErrorBoundary extends React.Component { .
{error.toString()}
- {errorActions} +
); /* eslint-enable material-ui/no-hardcoded-labels */ @@ -46,8 +49,9 @@ export default class DemoErrorBoundary extends React.Component { DemoErrorBoundary.propTypes = { children: PropTypes.node, + onResetDemoClick: PropTypes.func.isRequired, /** - * actions that should be displayed when the error fallback is displayed + * translate function from redux store */ - errorActions: PropTypes.node, + t: PropTypes.func.isRequired, }; diff --git a/docs/src/modules/components/DemoSandboxed.js b/docs/src/modules/components/DemoSandboxed.js index dda6a3ca5478d3..e02cbe37b445b3 100644 --- a/docs/src/modules/components/DemoSandboxed.js +++ b/docs/src/modules/components/DemoSandboxed.js @@ -3,7 +3,6 @@ import PropTypes from 'prop-types'; import { create } from 'jss'; import { withStyles, useTheme, jssPreset, StylesProvider } from '@material-ui/core/styles'; import NoSsr from '@material-ui/core/NoSsr'; -import Button from '@material-ui/core/Button'; import rtl from 'jss-rtl'; import Frame from 'react-frame-component'; import { useSelector } from 'react-redux'; @@ -87,20 +86,14 @@ const StyledFrame = withStyles(styles)(DemoFrame); * to an `iframe` if `iframe={true}`. */ function DemoSandboxed(props) { - const { component: Component, iframe, name, resetDemo, ...other } = props; + const { component: Component, iframe, name, onResetDemoClick, ...other } = props; const Sandbox = iframe ? StyledFrame : React.Fragment; const sandboxProps = iframe ? { title: `${name} demo`, ...other } : {}; const t = useSelector(state => state.options.t); return ( - - {t('resetDemo')} - - } - > + @@ -112,7 +105,7 @@ DemoSandboxed.propTypes = { component: PropTypes.elementType.isRequired, iframe: PropTypes.bool, name: PropTypes.string.isRequired, - resetDemo: PropTypes.func.isRequired, + onResetDemoClick: PropTypes.func.isRequired, }; export default React.memo(DemoSandboxed);