Skip to content

Commit

Permalink
Merge pull request #3556 from jaytula/usestyles-node-actions
Browse files Browse the repository at this point in the history
[RFR] Change to useStyles for NodeActions component
  • Loading branch information
djhi authored Aug 21, 2019
2 parents f383600 + 8348d41 commit 8d0594a
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions packages/ra-tree-ui-materialui/src/NodeActions.js
Original file line number Diff line number Diff line change
@@ -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 (
<span className={classes.root}>
{Children.map(children, action =>
action ? cloneElement(action, props) : null
)}
</span>
);
}
return (
<span className={classes.root}>
{Children.map(children, action =>
action ? cloneElement(action, props) : null
)}
</span>
);
}

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;

0 comments on commit 8d0594a

Please sign in to comment.