Skip to content

Commit

Permalink
Merge pull request #303 from 10up/upkeep/hook-use-taxonomy
Browse files Browse the repository at this point in the history
upkeep: add TS support for `useTaxonomy` hook
  • Loading branch information
fabiankaegy authored May 3, 2024
2 parents 235ddb2 + 8eadb72 commit b4257aa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hooks/use-taxonomy/index.js → hooks/use-taxonomy/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import type { Taxonomy } from '@wordpress/core-data';

export function useTaxonomy(taxonomyName) {
export function useTaxonomy(taxonomyName: string) {
return useSelect(
(select) => {
const { getTaxonomy, hasFinishedResolution } = select(coreStore);
Expand All @@ -12,5 +13,5 @@ export function useTaxonomy(taxonomyName) {
return [taxonomy, hasResolvedTaxonomy];
},
[taxonomyName],
);
) as [ taxonomy: Taxonomy | undefined, hasResolvedTaxonomy: boolean ];
}

0 comments on commit b4257aa

Please sign in to comment.