remove withRouter where not needed

This commit is contained in:
Keith J. Grant 2021-07-14 09:10:20 -07:00
parent 4c62bf268d
commit 9d01334a86
4 changed files with 10 additions and 20 deletions

View File

@ -3,7 +3,7 @@ import React, { Fragment, useState } from 'react';
import PropTypes from 'prop-types';
import { t } from '@lingui/macro';
import { withRouter } from 'react-router-dom';
import { useLocation } from 'react-router-dom';
import {
Button,
ButtonVariant,
@ -36,7 +36,6 @@ function Search({
onReplaceSearch,
onRemove,
qsConfig,
location,
searchableKeys,
relatedSearchableKeys,
onShowAdvancedSearch,
@ -45,6 +44,7 @@ function Search({
enableNegativeFiltering,
enableRelatedFuzzyFiltering,
}) {
const location = useLocation();
const [isSearchDropdownOpen, setIsSearchDropdownOpen] = useState(false);
const [searchKey, setSearchKey] = useState(
(() => {
@ -341,4 +341,4 @@ Search.defaultProps = {
enableRelatedFuzzyFiltering: true,
};
export default withRouter(Search);
export default Search;

View File

@ -1,7 +1,7 @@
import React, { Fragment, useState } from 'react';
import PropTypes from 'prop-types';
import { useLocation, withRouter } from 'react-router-dom';
import { useLocation } from 'react-router-dom';
import { t } from '@lingui/macro';
import {
Button,
@ -147,7 +147,4 @@ Sort.defaultProps = {
onSort: null,
};
export { Sort as _Sort };
const Wrapped = withRouter(Sort);
Wrapped.displayName = 'Sort';
export default Wrapped;
export default Sort;

View File

@ -6,7 +6,7 @@ import {
waitForElement,
} from '../../../testUtils/enzymeHelpers';
import Sort, { _Sort as SortUnwrapped } from './Sort';
import Sort from './Sort';
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
@ -167,7 +167,7 @@ describe('<Sort />', () => {
const numericColumns = [{ name: 'ID', key: 'id' }];
const wrapper = shallow(
<SortUnwrapped
<Sort
qsConfig={qsConfigNumDown}
columns={numericColumns}
onSort={jest.fn()}
@ -186,7 +186,7 @@ describe('<Sort />', () => {
const numericColumns = [{ name: 'ID', key: 'id' }];
const wrapper = shallow(
<SortUnwrapped
<Sort
qsConfig={qsConfigNumUp}
columns={numericColumns}
onSort={jest.fn()}
@ -205,7 +205,7 @@ describe('<Sort />', () => {
const alphaColumns = [{ name: 'Name', key: 'name' }];
const wrapper = shallow(
<SortUnwrapped
<Sort
qsConfig={qsConfigAlphaDown}
columns={alphaColumns}
onSort={jest.fn()}
@ -224,7 +224,7 @@ describe('<Sort />', () => {
const alphaColumns = [{ name: 'Name', key: 'name' }];
const wrapper = shallow(
<SortUnwrapped
<Sort
qsConfig={qsConfigAlphaDown}
columns={alphaColumns}
onSort={jest.fn()}

View File

@ -202,13 +202,6 @@ describe('<UserAndTeamAccessAdd/>', () => {
})
);
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useParams: () => ({
id: 'a',
}),
}));
await act(async () =>
wrapper.find('SelectableCard[label="Job templates"]').prop('onClick')({
fetchItems: JobTemplatesAPI.read,