index.js
4 years ago
useAuthors.js
4 years ago
useDebounceState.js
4 years ago
useDeviceType.js
4 years ago
useInnerBlocksCount.js
4 years ago
useTaxonomies.js
4 years ago
useTaxonomyRecords.js
4 years ago
useTaxonomyRecords.js
19 lines
| 1 | import { useSelect } from '@wordpress/data'; |
| 2 | import { store as coreStore } from '@wordpress/core-data'; |
| 3 | |
| 4 | export default ( taxonomy ) => ( |
| 5 | useSelect( ( select ) => { |
| 6 | const { |
| 7 | getEntityRecords, |
| 8 | isResolving, |
| 9 | } = select( coreStore ); |
| 10 | |
| 11 | const entityParams = [ 'taxonomy', taxonomy, { per_page: -1 } ]; |
| 12 | |
| 13 | return { |
| 14 | taxonomies: getEntityRecords( ...entityParams ) || [], |
| 15 | isResolving: isResolving( 'getEntityRecords', entityParams ), |
| 16 | }; |
| 17 | }, [ taxonomy ] ) |
| 18 | ); |
| 19 |