From 49f28424f7eb62e9925a132737d86bc8816bb851 Mon Sep 17 00:00:00 2001 From: fzaninotto Date: Fri, 13 Sep 2019 14:18:30 +0200 Subject: [PATCH 1/3] Cleanup a few components --- docs/List.md | 91 +++++----- examples/demo/src/layout/Login.js | 2 +- packages/ra-ui-materialui/src/Link.tsx | 42 +++-- .../src/list/BulkDeleteAction.js | 58 +++---- packages/ra-ui-materialui/src/list/Filter.js | 35 ++-- .../ra-ui-materialui/src/list/FilterButton.js | 164 ++++++++---------- .../src/list/FilterButton.spec.js | 3 +- .../src/list/FilterButtonMenuItem.js | 56 +++--- .../src/list/SingleFieldList.spec.js | 16 +- 9 files changed, 221 insertions(+), 246 deletions(-) diff --git a/docs/List.md b/docs/List.md index 9038f452b62..9a929d16488 100644 --- a/docs/List.md +++ b/docs/List.md @@ -687,25 +687,30 @@ The `List` component accepts the usual `className` prop but you can override man Here is an example of how you can override some of these classes: -You can customize the list styles by passing a `classes` object as prop, through `withStyles()`. Here is an example: +You can customize the list styles by passing a `classes` object as prop, through `useStyles()`. Here is an example: {% raw %} ```jsx -const styles = { +import { makeStyles } from '@material-ui/core'; + +const useStyles = makeStyles({ header: { backgroundColor: '#ccc', }, -}; +}); -const PostList = ({ classes, ...props }) => ( - - - ... - - -); +const PostList = props => { + const classes = useStyles(); + return ( + + + ... + + + ); +} -export withStyles(styles)(PostList); +export PostList; ``` {% endraw %} @@ -974,56 +979,64 @@ The `Datagrid` component accepts the usual `className` prop but you can override Here is an example of how you can override some of these classes: -You can customize the datagrid styles by passing a `classes` object as prop, through `withStyles()`. Here is an example: +You can customize the datagrid styles by passing a `classes` object as prop, through `useStyles()`. Here is an example: {% raw %} ```jsx -const styles = { +import { makeStyles } from '@material-ui/core'; + +const useStyles = makeStyles({ row: { backgroundColor: '#ccc', }, -}; +}); -const PostList = ({ classes, ...props) => ( - - - ... - - -); +const PostList = props => { + const classes = useStyles(); + return ( + + + ... + + + ); +} -export withStyles(styles)(PostList); +export PostList; ``` {% endraw %} **Tip**: If you want to override the `header` and `cell` styles independently for each column, use the `headerClassName` and `cellClassName` props in `` components. For instance, to hide a certain column on small screens: ```jsx -import { withStyles } from '@material-ui/core/styles'; +import { makeStyles } from '@material-ui/core'; -const styles = theme => ({ +const useStyles = makeStyles(theme => ({ hiddenOnSmallScreens: { [theme.breakpoints.down('md')]: { display: 'none', }, }, -}); +})); -const PostList = ({ classes, ...props }) => ( - - - - - - - -); +const PostList = props => { + const classes = usestyles(); + return ( + + + + + + + + ); +}; -export default withStyles(styles)(PostList); +export default PostList; ``` ## The `` component diff --git a/examples/demo/src/layout/Login.js b/examples/demo/src/layout/Login.js index afdc006d538..22d656c507d 100644 --- a/examples/demo/src/layout/Login.js +++ b/examples/demo/src/layout/Login.js @@ -163,7 +163,7 @@ Login.propTypes = { }; // We need to put the ThemeProvider decoration in another component -// Because otherwise the withStyles() HOC used in EnhancedLogin won't get +// Because otherwise the useStyles() hook used in Login won't get // the right theme const LoginWithTheme = props => ( diff --git a/packages/ra-ui-materialui/src/Link.tsx b/packages/ra-ui-materialui/src/Link.tsx index 97d573e929c..e62fab62dff 100644 --- a/packages/ra-ui-materialui/src/Link.tsx +++ b/packages/ra-ui-materialui/src/Link.tsx @@ -2,29 +2,41 @@ import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { Link as RRLink } from 'react-router-dom'; -import { withStyles, createStyles } from '@material-ui/core/styles'; +import { makeStyles } from '@material-ui/core/styles'; -const styles = theme => - createStyles({ - link: { - textDecoration: 'none', - color: theme.palette.primary.main, - }, - }); +const useStyles = makeStyles(theme => ({ + link: { + textDecoration: 'none', + color: theme.palette.primary.main, + }, +})); /** * @deprecated Use react-router-dom's Link instead */ -const Link = ({ to, children, className, classes, ...rest }) => ( - - {children} - -); +const Link = ({ + to, + children, + classes: classesOverride, + className, + ...rest +}) => { + const classes = useStyles({ classes: classesOverride }); + return ( + + {children} + + ); +}; + Link.propTypes = { className: PropTypes.string, - classes: PropTypes.object, children: PropTypes.node, to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), }; -export default withStyles(styles)(Link); +export default Link; diff --git a/packages/ra-ui-materialui/src/list/BulkDeleteAction.js b/packages/ra-ui-materialui/src/list/BulkDeleteAction.js index 0a0ccff9146..4784329e3b5 100644 --- a/packages/ra-ui-materialui/src/list/BulkDeleteAction.js +++ b/packages/ra-ui-materialui/src/list/BulkDeleteAction.js @@ -1,64 +1,48 @@ -import { Component } from 'react'; +import { useEffect } from 'react'; import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; -import compose from 'recompose/compose'; -import { crudDeleteMany, startUndoable, translate } from 'ra-core'; +import { useDispatch } from 'react-redux'; +import { crudDeleteMany, startUndoable } from 'ra-core'; -class BulkDeleteAction extends Component { - componentDidMount = () => { +/** + *@deprecated use BulkDeleteButton instead + */ +const BulkDeleteAction = props => { + const dispatch = useDispatch(); + + useEffect(() => { if (process.env.NODE_ENV !== 'production') { // eslint-disable-next-line no-console console.warn( ' is deprecated. Use the component instead, via the bulkActionButton props.' ); } - const { - basePath, - dispatchCrudDeleteMany, - resource, - selectedIds, - startUndoable, - undoable, - } = this.props; + const { basePath, resource, selectedIds, undoable, onExit } = props; if (undoable) { - startUndoable(crudDeleteMany(resource, selectedIds, basePath)); + dispatch( + startUndoable(crudDeleteMany(resource, selectedIds, basePath)) + ); } else { - dispatchCrudDeleteMany(resource, selectedIds, basePath); + dispatch(crudDeleteMany(resource, selectedIds, basePath)); } - this.props.onExit(); - }; + onExit(); + }, [dispatch, props]); - render() { - return null; - } -} + return null; +}; BulkDeleteAction.propTypes = { basePath: PropTypes.string, - dispatchCrudDeleteMany: PropTypes.func.isRequired, label: PropTypes.string, onExit: PropTypes.func.isRequired, resource: PropTypes.string.isRequired, - startUndoable: PropTypes.func, selectedIds: PropTypes.arrayOf(PropTypes.any).isRequired, translate: PropTypes.func.isRequired, undoable: PropTypes.bool, }; -const EnhancedBulkDeleteAction = compose( - connect( - undefined, - { - startUndoable, - dispatchCrudDeleteMany: crudDeleteMany, - } - ), - translate -)(BulkDeleteAction); - -EnhancedBulkDeleteAction.defaultProps = { +BulkDeleteAction.defaultProps = { label: 'ra.action.delete', undoable: true, }; -export default EnhancedBulkDeleteAction; +export default BulkDeleteAction; diff --git a/packages/ra-ui-materialui/src/list/Filter.js b/packages/ra-ui-materialui/src/list/Filter.js index b9f393cb946..718091c4de7 100644 --- a/packages/ra-ui-materialui/src/list/Filter.js +++ b/packages/ra-ui-materialui/src/list/Filter.js @@ -1,20 +1,20 @@ -import React, { Component } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; +import { makeStyles } from '@material-ui/core/styles'; import { sanitizeListRestProps } from 'ra-core'; import FilterForm from './FilterForm'; import FilterButton from './FilterButton'; -const styles = { +const useStyles = makeStyles({ button: {}, form: {}, -}; +}); -export class Filter extends Component { - renderButton() { +const Filter = props => { + const classes = useStyles({ classes: props.classes }); + const renderButton = () => { const { - classes = {}, context, resource, children, @@ -24,7 +24,7 @@ export class Filter extends Component { filterValues, variant, ...rest - } = this.props; + } = props; return ( ); - } + }; - renderForm() { + const renderForm = () => { const { - classes = {}, context, resource, children, @@ -51,7 +50,7 @@ export class Filter extends Component { filterValues, setFilters, ...rest - } = this.props; + } = props; return ( ); - } + }; - render() { - return this.props.context === 'button' - ? this.renderButton() - : this.renderForm(); - } -} + return props.context === 'button' ? renderButton() : renderForm(); +}; Filter.propTypes = { children: PropTypes.node, @@ -86,4 +81,4 @@ Filter.propTypes = { resource: PropTypes.string.isRequired, }; -export default withStyles(styles)(Filter); +export default Filter; diff --git a/packages/ra-ui-materialui/src/list/FilterButton.js b/packages/ra-ui-materialui/src/list/FilterButton.js index 457222d39cd..4d782551113 100644 --- a/packages/ra-ui-materialui/src/list/FilterButton.js +++ b/packages/ra-ui-materialui/src/list/FilterButton.js @@ -1,109 +1,89 @@ -import React, { Component } from 'react'; +import React, { useState, useCallback, useRef } from 'react'; import PropTypes from 'prop-types'; import Menu from '@material-ui/core/Menu'; -import { withStyles, createStyles } from '@material-ui/core/styles'; +import { makeStyles } from '@material-ui/core/styles'; import ContentFilter from '@material-ui/icons/FilterList'; import classnames from 'classnames'; -import compose from 'recompose/compose'; -import { translate } from 'ra-core'; import lodashGet from 'lodash/get'; import FilterButtonMenuItem from './FilterButtonMenuItem'; import Button from '../button/Button'; -const styles = createStyles({ +const useStyles = makeStyles({ root: { display: 'inline-block' }, }); -export class FilterButton extends Component { - constructor(props) { - super(props); - this.state = { - open: false, - anchorEl: null, - }; - this.handleClickButton = this.handleClickButton.bind(this); - this.handleRequestClose = this.handleRequestClose.bind(this); - this.handleShow = this.handleShow.bind(this); - } +const FilterButton = ({ + filters, + displayedFilters, + filterValues, + showFilter, + classes: classesOverride, + className, + resource, + ...rest +}) => { + const [open, setOpen] = useState(false); + const anchorEl = useRef(); + const classes = useStyles({ classes: classesOverride }); - getHiddenFilters() { - const { filters, displayedFilters, filterValues } = this.props; - return filters.filter( - filterElement => - !filterElement.props.alwaysOn && - !displayedFilters[filterElement.props.source] && - typeof lodashGet(filterValues, filterElement.props.source) === - 'undefined' - ); - } + const hiddenFilters = filters.filter( + filterElement => + !filterElement.props.alwaysOn && + !displayedFilters[filterElement.props.source] && + typeof lodashGet(filterValues, filterElement.props.source) === + 'undefined' + ); - handleClickButton(event) { - // This prevents ghost click. - event.preventDefault(); + const handleClickButton = useCallback( + event => { + // This prevents ghost click. + event.preventDefault(); + setOpen(true); + anchorEl.current = event.currentTarget; + }, + [anchorEl] + ); - this.setState({ - open: true, - anchorEl: event.currentTarget, - }); - } + const handleRequestClose = useCallback(() => { + setOpen(false); + }, []); - handleRequestClose() { - this.setState({ - open: false, - }); - } + const handleShow = useCallback( + ({ source, defaultValue }) => { + showFilter(source, defaultValue); + setOpen(false); + }, + [showFilter] + ); - handleShow({ source, defaultValue }) { - this.props.showFilter(source, defaultValue); - this.setState({ - open: false, - }); - } - - render() { - const hiddenFilters = this.getHiddenFilters(); - const { - classes = {}, - className, - resource, - showFilter, - displayedFilters, - filterValues, - translate, - ...rest - } = this.props; - const { open, anchorEl } = this.state; - - return ( - hiddenFilters.length > 0 && ( -
- - - {hiddenFilters.map(filterElement => ( - - ))} - -
- ) - ); - } -} + if (hiddenFilters.length === 0) return null; + return ( +
+ + + {hiddenFilters.map(filterElement => ( + + ))} + +
+ ); +}; FilterButton.propTypes = { resource: PropTypes.string.isRequired, @@ -111,12 +91,8 @@ FilterButton.propTypes = { displayedFilters: PropTypes.object.isRequired, filterValues: PropTypes.object.isRequired, showFilter: PropTypes.func.isRequired, - translate: PropTypes.func.isRequired, classes: PropTypes.object, className: PropTypes.string, }; -export default compose( - translate, - withStyles(styles) -)(FilterButton); +export default FilterButton; diff --git a/packages/ra-ui-materialui/src/list/FilterButton.spec.js b/packages/ra-ui-materialui/src/list/FilterButton.spec.js index 04aa30ba58b..ebab90e6d83 100644 --- a/packages/ra-ui-materialui/src/list/FilterButton.spec.js +++ b/packages/ra-ui-materialui/src/list/FilterButton.spec.js @@ -4,7 +4,7 @@ import { render, cleanup, fireEvent } from '@testing-library/react'; import { ThemeProvider } from '@material-ui/styles'; import { createMuiTheme } from '@material-ui/core'; -import { FilterButton } from './FilterButton'; +import FilterButton from './FilterButton'; import TextInput from '../input/TextInput'; const theme = createMuiTheme(); @@ -21,7 +21,6 @@ describe('', () => { 'customer.name': true, }, showFilter: () => {}, - translate: () => {}, filterValues: {}, }; diff --git a/packages/ra-ui-materialui/src/list/FilterButtonMenuItem.js b/packages/ra-ui-materialui/src/list/FilterButtonMenuItem.js index db2558b4a66..01308e2f57c 100644 --- a/packages/ra-ui-materialui/src/list/FilterButtonMenuItem.js +++ b/packages/ra-ui-materialui/src/list/FilterButtonMenuItem.js @@ -1,39 +1,35 @@ -import React, { Component } from 'react'; +import React, { forwardRef, useCallback } from 'react'; import PropTypes from 'prop-types'; import MenuItem from '@material-ui/core/MenuItem'; import { FieldTitle } from 'ra-core'; -class FilterButtonMenuItem extends Component { - static propTypes = { - filter: PropTypes.object.isRequired, - onShow: PropTypes.func.isRequired, - resource: PropTypes.string.isRequired, - }; - - handleShow = () => { - const { filter, onShow } = this.props; +const FilterButtonMenuItem = forwardRef(({ filter, onShow, resource }, ref) => { + const handleShow = useCallback(() => { onShow({ source: filter.source, defaultValue: filter.defaultValue }); - }; + }, [filter.defaultValue, filter.source, onShow]); - render() { - const { filter, resource } = this.props; + return ( + + + + ); +}); - return ( - - - - ); - } -} +FilterButtonMenuItem.propTypes = { + filter: PropTypes.object.isRequired, + onShow: PropTypes.func.isRequired, + resource: PropTypes.string.isRequired, +}; export default FilterButtonMenuItem; diff --git a/packages/ra-ui-materialui/src/list/SingleFieldList.spec.js b/packages/ra-ui-materialui/src/list/SingleFieldList.spec.js index 64d7ca7df99..0fa69802177 100644 --- a/packages/ra-ui-materialui/src/list/SingleFieldList.spec.js +++ b/packages/ra-ui-materialui/src/list/SingleFieldList.spec.js @@ -20,7 +20,7 @@ describe('', () => { ); - const linkElements = wrapper.find('WithStyles(Link)'); + const linkElements = wrapper.find('Link'); assert.equal(linkElements.length, 2); assert.deepEqual(linkElements.map(link => link.prop('to')), [ '/posts/1', @@ -42,7 +42,7 @@ describe('', () => { ); - const linkElements = wrapper.find('WithStyles(Link)'); + const linkElements = wrapper.find('Link'); assert.equal(linkElements.length, 2); assert.deepEqual(linkElements.map(link => link.prop('to')), [ '/posts/1', @@ -64,7 +64,7 @@ describe('', () => { ); - let linkElements = wrapper.find('WithStyles(Link)'); + let linkElements = wrapper.find('Link'); assert.equal(linkElements.length, 2); assert.deepEqual(linkElements.map(link => link.prop('to')), [ '/edit/1', @@ -84,7 +84,7 @@ describe('', () => { ); - linkElements = wrapper.find('WithStyles(Link)'); + linkElements = wrapper.find('Link'); assert.equal(linkElements.length, 2); assert.deepEqual(linkElements.map(link => link.prop('to')), [ '/show/1', @@ -108,7 +108,7 @@ describe('', () => { ); - const linkElements = wrapper.find('WithStyles(Link)'); + const linkElements = wrapper.find('Link'); assert.equal(linkElements.length, 2); assert.deepEqual(linkElements.map(link => link.prop('to')), [ '/prefix/bar/1/show', @@ -131,7 +131,7 @@ describe('', () => { ); - let linkElements = wrapper.find('WithStyles(Link)'); + let linkElements = wrapper.find('Link'); assert.equal(linkElements.length, 2); assert.deepEqual(linkElements.map(link => link.prop('to')), [ '/edit/1/show', @@ -152,7 +152,7 @@ describe('', () => { ); - linkElements = wrapper.find('WithStyles(Link)'); + linkElements = wrapper.find('Link'); assert.equal(linkElements.length, 2); assert.deepEqual(linkElements.map(link => link.prop('to')), [ '/show/1/show', @@ -176,7 +176,7 @@ describe('', () => { ); - const linkElements = wrapper.find('WithStyles(Link)'); + const linkElements = wrapper.find('Link'); assert.equal(linkElements.length, 0); const chipElements = wrapper.find('EnhancedChipField'); assert.equal(chipElements.length, 2); From 80e736c0b33541319a37455f564b9588a2b696cf Mon Sep 17 00:00:00 2001 From: fzaninotto Date: Fri, 13 Sep 2019 14:25:08 +0200 Subject: [PATCH 2/3] Cleanup warnings --- examples/simple/src/comments/index.js | 1 - packages/ra-core/src/controller/useShowController.ts | 3 +-- packages/ra-core/src/dataProvider/useGetMany.spec.tsx | 7 +------ packages/ra-core/src/dataProvider/useGetMany.ts | 5 +++-- packages/ra-ui-materialui/src/field/FileField.tsx | 2 +- packages/ra-ui-materialui/src/field/ImageField.tsx | 2 +- .../ra-ui-materialui/src/input/CheckboxGroupInputItem.tsx | 5 +++-- 7 files changed, 10 insertions(+), 15 deletions(-) diff --git a/examples/simple/src/comments/index.js b/examples/simple/src/comments/index.js index cd4bbeeed41..f959929032e 100644 --- a/examples/simple/src/comments/index.js +++ b/examples/simple/src/comments/index.js @@ -2,7 +2,6 @@ import ChatBubbleIcon from '@material-ui/icons/ChatBubble'; import CommentCreate from './CommentCreate'; import CommentEdit from './CommentEdit'; import CommentList from './CommentList'; -import CommentShow from './CommentShow'; import { ShowGuesser } from 'react-admin'; export default { diff --git a/packages/ra-core/src/controller/useShowController.ts b/packages/ra-core/src/controller/useShowController.ts index 2d0e9a264c8..540a8ac039d 100644 --- a/packages/ra-core/src/controller/useShowController.ts +++ b/packages/ra-core/src/controller/useShowController.ts @@ -15,7 +15,6 @@ export interface ShowProps { hasList?: boolean; id: Identifier; resource: string; - undoable?: boolean; [key: string]: any; } @@ -48,7 +47,7 @@ export interface ShowControllerProps { */ const useShowController = (props: ShowProps): ShowControllerProps => { useCheckMinimumRequiredProps('Show', ['basePath', 'resource'], props); - const { basePath, id, resource, undoable = true } = props; + const { basePath, id, resource } = props; const translate = useTranslate(); const notify = useNotify(); const redirect = useRedirect(); diff --git a/packages/ra-core/src/dataProvider/useGetMany.spec.tsx b/packages/ra-core/src/dataProvider/useGetMany.spec.tsx index 57431cb2ec5..a3c031d2793 100644 --- a/packages/ra-core/src/dataProvider/useGetMany.spec.tsx +++ b/packages/ra-core/src/dataProvider/useGetMany.spec.tsx @@ -19,11 +19,6 @@ const UseGetMany = ({ }; describe('useGetMany', () => { - const defaultProps = { - ids: [1], - resource: 'posts', - }; - afterEach(cleanup); it('should call the dataProvider with a GET_MANY on mount', async () => { @@ -100,7 +95,7 @@ describe('useGetMany', () => { .mockReturnValueOnce( Promise.resolve({ data: [{ id: 5 }, { id: 6 }, { id: 7 }] }) ); - const { dispatch } = renderWithRedux( + renderWithRedux( diff --git a/packages/ra-core/src/dataProvider/useGetMany.ts b/packages/ra-core/src/dataProvider/useGetMany.ts index 2768f07bd4b..1a339d00775 100644 --- a/packages/ra-core/src/dataProvider/useGetMany.ts +++ b/packages/ra-core/src/dataProvider/useGetMany.ts @@ -186,8 +186,9 @@ const callQueries = debounce(() => { loaded: true, })); if (onSuccess) { - const subData = ids.map(id => - response.data.find(datum => datum.id == id) + const subData = ids.map( + id => + response.data.find(datum => datum.id == id) // eslint-disable-line eqeqeq ); onSuccess({ data: subData }); } diff --git a/packages/ra-ui-materialui/src/field/FileField.tsx b/packages/ra-ui-materialui/src/field/FileField.tsx index 3243542fd3a..f73811d6559 100644 --- a/packages/ra-ui-materialui/src/field/FileField.tsx +++ b/packages/ra-ui-materialui/src/field/FileField.tsx @@ -1,4 +1,4 @@ -import React, { SFC, ComponentType } from 'react'; +import React, { SFC } from 'react'; import PropTypes from 'prop-types'; import get from 'lodash/get'; import { makeStyles } from '@material-ui/core/styles'; diff --git a/packages/ra-ui-materialui/src/field/ImageField.tsx b/packages/ra-ui-materialui/src/field/ImageField.tsx index 5b105b2066e..158f7cb686f 100644 --- a/packages/ra-ui-materialui/src/field/ImageField.tsx +++ b/packages/ra-ui-materialui/src/field/ImageField.tsx @@ -1,4 +1,4 @@ -import React, { SFC, ComponentType } from 'react'; +import React, { SFC } from 'react'; import PropTypes from 'prop-types'; import get from 'lodash/get'; import { makeStyles } from '@material-ui/core/styles'; diff --git a/packages/ra-ui-materialui/src/input/CheckboxGroupInputItem.tsx b/packages/ra-ui-materialui/src/input/CheckboxGroupInputItem.tsx index 58afea759fa..5390e8097cf 100644 --- a/packages/ra-ui-materialui/src/input/CheckboxGroupInputItem.tsx +++ b/packages/ra-ui-materialui/src/input/CheckboxGroupInputItem.tsx @@ -42,8 +42,9 @@ const CheckboxGroupInputItem = ({ className={classes.checkbox} checked={ value - ? value.find(v => v == get(choice, optionValue)) !== - undefined // eslint-disable-line eqeqeq + ? value.find( + v => v == get(choice, optionValue) // eslint-disable-line eqeqeq + ) !== undefined : false } value={String(get(choice, optionValue))} From ab35db3a527c4d6ddc0cfcd4aa760946dc7c1e14 Mon Sep 17 00:00:00 2001 From: fzaninotto Date: Fri, 13 Sep 2019 14:26:20 +0200 Subject: [PATCH 3/3] Cleanup more warnings --- .../src/controller/input/useGetMatchingReferences.spec.tsx | 2 +- packages/ra-core/src/controller/usePaginationState.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ra-core/src/controller/input/useGetMatchingReferences.spec.tsx b/packages/ra-core/src/controller/input/useGetMatchingReferences.spec.tsx index 20166048f65..13a917e4f6f 100644 --- a/packages/ra-core/src/controller/input/useGetMatchingReferences.spec.tsx +++ b/packages/ra-core/src/controller/input/useGetMatchingReferences.spec.tsx @@ -19,7 +19,7 @@ describe('useMatchingReferences', () => { afterEach(cleanup); it('should fetch matchingReferences only on mount', () => { - const { dispatch, rerender } = renderHook(() => { + const { dispatch } = renderHook(() => { return useMatchingReferences(defaultProps); }); diff --git a/packages/ra-core/src/controller/usePaginationState.ts b/packages/ra-core/src/controller/usePaginationState.ts index da6e7c0f646..6ae102ab1e3 100644 --- a/packages/ra-core/src/controller/usePaginationState.ts +++ b/packages/ra-core/src/controller/usePaginationState.ts @@ -1,4 +1,4 @@ -import { useState, useEffect, useReducer, useCallback, useRef } from 'react'; +import { useEffect, useReducer, useCallback, useRef } from 'react'; import { Pagination } from '../types'; interface PaginationProps {