Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UNRELEASED-V4.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f
- Upgraded the `Autocomplete` component from legacy context API to use createContext ([#1403](https://github.com/Shopify/polaris-react/pull/1403))
- Removed testID warning in tests ([#1447](https://github.com/Shopify/polaris-react/pull/1447))
- Updated `ThemeProvider` to use the new context api ([#1396](https://github.com/Shopify/polaris-react/pull/1396))
- Removed `withContext` from `ResourceList.Item` ([#1503](https://github.com/Shopify/polaris-react/pull/1503))
- Updated `AppProvider` to no longer use `componentWillReceiveProps`([#1255](https://github.com/Shopify/polaris-react/pull/1255))
- Removed `withContext` from `Scrollable.ScrollTo` and added a test to boost coverage ([#1499](https://github.com/Shopify/polaris-react/pull/1499))
- Removed `withContext` from `ResourceList.FilterControl` ([#1500](https://github.com/Shopify/polaris-react/pull/1500))
Expand Down
19 changes: 10 additions & 9 deletions src/components/ResourceList/components/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import {HorizontalDotsMinor} from '@shopify/polaris-icons';
import {classNames} from '@shopify/css-utilities';
import {createUniqueIDFactory} from '@shopify/javascript-utilities/other';
import compose from '@shopify/react-compose';
import isEqual from 'lodash/isEqual';
import {DisableableAction, WithContextTypes} from '../../../../types';
import ActionList from '../../../ActionList';
Expand All @@ -16,7 +15,6 @@ import Button, {buttonsFrom} from '../../../Button';
import {withAppProvider, WithAppProviderProps} from '../../../AppProvider';

import {SELECT_ALL_ITEMS, SelectedItems} from '../../types';
import withContext from '../../../WithContext';
import ResourceListContext, {ResourceListContextType} from '../../context';
import styles from './Item.scss';

Expand Down Expand Up @@ -69,7 +67,7 @@ export type CombinedProps =
const getUniqueCheckboxID = createUniqueIDFactory('ResourceListItemCheckbox');
const getUniqueOverlayID = createUniqueIDFactory('ResourceListItemOverlay');

export class Item extends React.Component<CombinedProps, State> {
export class BaseItem extends React.Component<CombinedProps, State> {
static getDerivedStateFromProps(nextProps: CombinedProps, prevState: State) {
const selected = isSelected(nextProps.id, nextProps.context.selectedItems);

Expand Down Expand Up @@ -411,9 +409,12 @@ function isSelected(id: string, selectedItems?: SelectedItems) {
);
}

export default compose<Props>(
withContext<Props, WithAppProviderProps, ResourceListContextType>(
ResourceListContext.Consumer,
),
withAppProvider<Props>(),
)(Item);
function Item(props: CombinedProps) {
return (
<ResourceListContext.Consumer>
{(context) => <BaseItem {...props} context={context} />}
</ResourceListContext.Consumer>
);
}

export default withAppProvider<Props>()(Item);