Skip to content

Commit

Permalink
Revert "Add useStoreSelectors hook (#26692)"
Browse files Browse the repository at this point in the history
This reverts commit 24a4f44.
  • Loading branch information
adamziel authored Nov 9, 2020
1 parent b21a82d commit aeeeb0f
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 171 deletions.
28 changes: 0 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"@storybook/addon-viewport": "5.3.2",
"@storybook/react": "6.0.21",
"@testing-library/react": "10.0.2",
"@testing-library/react-hooks": "3.4.2",
"@types/classnames": "2.2.10",
"@types/eslint": "6.8.0",
"@types/estree": "0.0.44",
Expand Down
4 changes: 0 additions & 4 deletions packages/data/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

## Unreleased

### New Feature

- Expose `useStoreSelectors` hook for usage in functional components. ([#26692](https://github.com/WordPress/gutenberg/pull/26692))

## 4.6.0 (2019-06-12)

### New Feature
Expand Down
42 changes: 0 additions & 42 deletions packages/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -712,48 +712,6 @@ _Returns_

- `Function`: A custom react hook.

<a name="useStoreSelectors" href="#useStoreSelectors">#</a> **useStoreSelectors**

Custom react hook for retrieving selectors from registered stores

_Usage_

```js
const { useStoreSelectors } = wp.data;

function HammerPriceDisplay( { currency } ) {
const price = useStoreSelectors(
'my-shop',
( { getPrice } ) => getPrice( 'hammer', currency ),
[ currency ]
);
return new Intl.NumberFormat( 'en-US', {
style: 'currency',
currency,
} ).format( price );
}

// Rendered in the application:
// <HammerPriceDisplay currency="USD" />
```

In the above example, when `HammerPriceDisplay` is rendered into an
application, the price will be retrieved from the store state using the
`mapSelectors` callback on `useStoreSelectors`. If the currency prop changes then
any price in the state for that currency is retrieved. If the currency prop
doesn't change and other props are passed in that do change, the price will
not change because the dependency is just the currency.

_Parameters_

- _storeKey_ `string`: Store to return selectors from.
- _mapSelectors_ `Function`: Function called on every state change. The returned value is exposed to the component implementing this hook. The function receives the object with all the store selectors as its only argument.
- _deps_ `Array`: If provided, this memoizes the mapSelect so the same `mapSelect` is invoked on every state change unless the dependencies change.

_Returns_

- `Function`: A custom react hook.

<a name="withDispatch" href="#withDispatch">#</a> **withDispatch**

Higher-order component used to add dispatch props using registered action
Expand Down
50 changes: 0 additions & 50 deletions packages/data/src/components/use-store-selectors/index.js

This file was deleted.

45 changes: 0 additions & 45 deletions packages/data/src/components/use-store-selectors/test/index.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/data/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export {
useRegistry,
} from './components/registry-provider';
export { default as useSelect } from './components/use-select';
export { default as useStoreSelectors } from './components/use-store-selectors';
export { useDispatch } from './components/use-dispatch';
export { AsyncModeProvider } from './components/async-mode-provider';
export { createRegistry } from './registry';
Expand Down

0 comments on commit aeeeb0f

Please sign in to comment.