Move convert function out of useSelect in useNewCampaignTypes.

This is so that it doesn't become dependency in useSelect.
This commit is contained in:
Gan Eng Chin 2023-03-09 21:42:59 +08:00
parent 97ed1d2a7d
commit 3ba492f32b
No known key found for this signature in database
GPG Key ID: 94D5D972860ADB01
1 changed files with 11 additions and 11 deletions

View File

@ -20,19 +20,19 @@ type UseNewCampaignTypes = {
error?: ApiFetchError;
};
export const useNewCampaignTypes = (): UseNewCampaignTypes => {
const convert = ( campaignType: APICampaignType ): CampaignType => {
return {
id: campaignType.id,
icon: campaignType.icon_url,
name: campaignType.name,
description: campaignType.description,
createUrl: campaignType.create_url,
channelName: campaignType.channel.name,
channelSlug: campaignType.channel.slug,
};
const convert = ( campaignType: APICampaignType ): CampaignType => {
return {
id: campaignType.id,
icon: campaignType.icon_url,
name: campaignType.name,
description: campaignType.description,
createUrl: campaignType.create_url,
channelName: campaignType.channel.name,
channelSlug: campaignType.channel.slug,
};
};
export const useNewCampaignTypes = (): UseNewCampaignTypes => {
return useSelect( ( select ) => {
const { hasFinishedResolution, getCampaignTypes } = select( STORE_KEY );
const campaignTypesState = getCampaignTypes< CampaignTypesState >();