diff --git a/examples/simple/src/posts/PostList.js b/examples/simple/src/posts/PostList.js
index 8ebfd9c012a..dfa70b14c2b 100644
--- a/examples/simple/src/posts/PostList.js
+++ b/examples/simple/src/posts/PostList.js
@@ -1,6 +1,6 @@
import BookIcon from '@material-ui/icons/Book';
import Chip from '@material-ui/core/Chip';
-import { withStyles } from '@material-ui/core/styles';
+import { makeStyles } from '@material-ui/core/styles';
import React, { Children, Fragment, cloneElement } from 'react';
import {
BooleanField,
@@ -46,7 +46,7 @@ const PostFilter = props => (
);
-const styles = theme => ({
+const useStyles = makeStyles(theme => ({
title: {
maxWidth: '20em',
overflow: 'hidden',
@@ -59,7 +59,7 @@ const styles = theme => ({
},
},
publishedAt: { fontStyle: 'italic' },
-});
+}));
const PostListBulkActions = props => (
@@ -68,16 +68,21 @@ const PostListBulkActions = props => (
);
-const PostListActionToolbar = withStyles({
+const usePostListActionToolbarStyles = makeStyles({
toolbar: {
alignItems: 'center',
display: 'flex',
},
-})(({ classes, children, ...props }) => (
-
- {Children.map(children, button => cloneElement(button, props))}
-
-));
+});
+
+const PostListActionToolbar = ({ children, ...props }) => {
+ const classes = usePostListActionToolbarStyles();
+ return (
+
+ {Children.map(children, button => cloneElement(button, props))}
+
+ );
+};
const rowClick = (id, basePath, record) => {
if (record.commentable) {
@@ -91,58 +96,64 @@ const PostPanel = ({ id, record, resource }) => (
);
-const PostList = withStyles(styles)(({ classes, ...props }) => (
-
- record.title}
- secondaryText={record => `${record.views} views`}
- tertiaryText={record =>
- new Date(record.published_at).toLocaleDateString()
- }
- />
- }
- medium={
-
-
-
- {
+ const classes = useStyles();
+ return (
+
+ record.title}
+ secondaryText={record => `${record.views} views`}
+ tertiaryText={record =>
+ new Date(record.published_at).toLocaleDateString()
+ }
/>
+ }
+ medium={
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
- }
- />
-
-));
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+ />
+
+ );
+};
export default PostList;
diff --git a/examples/simple/src/posts/ResetViewsButton.js b/examples/simple/src/posts/ResetViewsButton.js
index 8e8fbbe1dfb..242139cb6a6 100644
--- a/examples/simple/src/posts/ResetViewsButton.js
+++ b/examples/simple/src/posts/ResetViewsButton.js
@@ -1,35 +1,41 @@
-import React, { Component } from 'react';
+import React, { useCallback } from 'react';
import PropTypes from 'prop-types';
-import { connect } from 'react-redux';
+import { useDispatch } from 'react-redux';
import VisibilityOff from '@material-ui/icons/VisibilityOff';
import { startUndoable, crudUpdateMany, Button } from 'react-admin';
-class ResetViewsAction extends Component {
- handleClick = () => {
- const { basePath, startUndoable, resource, selectedIds } = this.props;
- startUndoable(
- crudUpdateMany(resource, selectedIds, { views: 0 }, basePath)
- );
- };
+const ResetViewsButton = props => {
+ const dispatch = useDispatch();
+ const { basePath, resource, selectedIds } = props;
- render() {
- return (
-
- );
- }
-}
+ const handleClick = useCallback(
+ () => {
+ dispatch(
+ startUndoable(
+ crudUpdateMany(
+ resource,
+ selectedIds,
+ { views: 0 },
+ basePath,
+ ),
+ ),
+ );
+ },
+ [basePath, resource, selectedIds],
+ );
-ResetViewsAction.propTypes = {
+ return (
+
+ );
+};
+
+ResetViewsButton.propTypes = {
basePath: PropTypes.string,
label: PropTypes.string,
resource: PropTypes.string.isRequired,
selectedIds: PropTypes.arrayOf(PropTypes.any).isRequired,
- startUndoable: PropTypes.func.isRequired,
};
-export default connect(
- undefined,
- { startUndoable }
-)(ResetViewsAction);
+export default ResetViewsButton;
diff --git a/examples/simple/src/tags/TagList.js b/examples/simple/src/tags/TagList.js
index c81227682b9..fb8866a1810 100644
--- a/examples/simple/src/tags/TagList.js
+++ b/examples/simple/src/tags/TagList.js
@@ -5,13 +5,11 @@ import {
List,
SaveButton,
ShowButton,
- TextField,
TextInput,
} from 'react-admin';
import {
DragPreview,
IgnoreFormProps,
- NodeView,
NodeForm,
Tree,
NodeActions,
diff --git a/examples/simple/src/users/UserEdit.js b/examples/simple/src/users/UserEdit.js
index ef6d758c7a1..588c5e39dfa 100644
--- a/examples/simple/src/users/UserEdit.js
+++ b/examples/simple/src/users/UserEdit.js
@@ -13,29 +13,32 @@ import {
Toolbar,
required,
} from 'react-admin';
-import { withStyles } from '@material-ui/core';
+import { makeStyles } from '@material-ui/core/styles';
import UserTitle from './UserTitle';
import Aside from './Aside';
-const toolbarStyles = {
+const useToolbarStyles = makeStyles({
toolbar: {
display: 'flex',
justifyContent: 'space-between',
},
-};
+});
/**
* Custom Toolbar for the Edit form
*
* Save with undo, but delete with confirm
*/
-const UserEditToolbar = withStyles(toolbarStyles)(props => (
-
-
-
-
-));
+const UserEditToolbar = props => {
+ const classes = useToolbarStyles();
+ return (
+
+
+
+
+ );
+};
const UserEdit = ({ permissions, ...props }) => (