diff --git a/packages/ra-tree-ui-materialui/src/NodeActions.js b/packages/ra-tree-ui-materialui/src/NodeActions.js index 8e239a1a95f..a0eed173970 100644 --- a/packages/ra-tree-ui-materialui/src/NodeActions.js +++ b/packages/ra-tree-ui-materialui/src/NodeActions.js @@ -1,34 +1,33 @@ -import React, { cloneElement, Children, Component } from 'react'; +import React, { cloneElement, Children } from 'react'; import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; +import { makeStyles } from '@material-ui/core/styles'; -const styles = theme => ({ +const useStyles = makeStyles(theme => ({ root: { alignItems: 'center', marginLeft: 'auto', marginRight: theme.spacing(4), }, -}); +})); -export class NodeActions extends Component { - static propTypes = { - classes: PropTypes.object.isRequired, - basePath: PropTypes.string.isRequired, - children: PropTypes.node, - record: PropTypes.object.isRequired, - resource: PropTypes.string.isRequired, - }; +function NodeActions({ children, classes: classesOverride, ...props }) { + const classes = useStyles({ classes: classesOverride }); - render() { - const { children, classes, ...props } = this.props; - return ( - - {Children.map(children, action => - action ? cloneElement(action, props) : null - )} - - ); - } + return ( + + {Children.map(children, action => + action ? cloneElement(action, props) : null + )} + + ); } -export default withStyles(styles)(NodeActions); +NodeActions.propTypes = { + classes: PropTypes.object.isRequired, + basePath: PropTypes.string.isRequired, + children: PropTypes.node, + record: PropTypes.object.isRequired, + resource: PropTypes.string.isRequired, +}; + +export default NodeActions;