diff --git a/__tests__/useCTA.test.ts b/__tests__/useCTA.test.ts index ffe323c..f60ffce 100644 --- a/__tests__/useCTA.test.ts +++ b/__tests__/useCTA.test.ts @@ -1857,7 +1857,7 @@ describe( 'useCTA', function() { { hi: state.current.hi * 3, }, - { useCustom: false, }, + { useDefault: true, }, ); }, }, diff --git a/src/internal/ActionTypes.ts b/src/internal/ActionTypes.ts index 9283faa..db6af37 100644 --- a/src/internal/ActionTypes.ts +++ b/src/internal/ActionTypes.ts @@ -5,7 +5,7 @@ type PredefinedActions = 'replace' | 'replaceInitial' | 'reset' | 'update'; export type ActionTypeConstructParam = { type: PredefinedActions nextState: Initial | Partial - options?: { useCustom: boolean } + options?: { useDefault: boolean } }; export class ActionType { @@ -17,7 +17,7 @@ export class ActionType { this.type = param.type; this.nextState = param.nextState; this.options = { - useCustom: true, + useDefault: false, ...param?.options, }; } diff --git a/src/internal/ctaReducer.ts b/src/internal/ctaReducer.ts index bb4094f..ae25b30 100644 --- a/src/internal/ctaReducer.ts +++ b/src/internal/ctaReducer.ts @@ -212,15 +212,15 @@ function getActionType< return { next: nextState, type, - useCustom: Boolean( options?.useCustom, ), + useDefault: Boolean( options?.useDefault, ), } as typeof type extends 'update' ? { next: Partial type: 'update' - useCustom: boolean + useDefault: boolean } : { next: Initial type: Exclude - useCustom: boolean + useDefault: boolean }; } @@ -228,7 +228,7 @@ function getActionType< return { next: ctaReturnType as Partial, type: 'update' as Extract, - useCustom: true, + useDefault: false, }; } } @@ -346,7 +346,7 @@ export default function ctaReducer< const { type, - useCustom, + useDefault, } = actionType; let { @@ -355,7 +355,7 @@ export default function ctaReducer< const customPredefinedCTA = isActionsObject && actions?.[ type as keyof typeof actions ]; - if ( typeof customPredefinedCTA === 'function' && useCustom ) { + if ( typeof customPredefinedCTA === 'function' && !useDefault ) { next = customPredefinedCTA( ctaHandleState, next, ); }