[IMPROVE] Throw error if no appId is provided to useUIKitHandleAction (#23221)

pull/23117/head^2
gabriellsh 4 years ago committed by GitHub
parent 0a293e547f
commit 5f560962f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      client/UIKit/hooks/useUIKitHandleAction.tsx

@ -13,8 +13,11 @@ import { UiKitPayload, UIKitActionEvent } from '../../../definition/UIKit';
const useUIKitHandleAction = <S extends UiKitPayload>(
state: S,
): ((event: UIKitActionEvent) => Promise<void>) =>
useMutableCallback(async ({ blockId, value, appId, actionId }) =>
ActionManager.triggerBlockAction({
useMutableCallback(async ({ blockId, value, appId, actionId }) => {
if (!appId) {
throw new Error('useUIKitHandleAction - invalid appId');
}
return ActionManager.triggerBlockAction({
container: {
type: UIKitIncomingInteractionContainerType.VIEW,
id: state.viewId || state.appId,
@ -23,7 +26,7 @@ const useUIKitHandleAction = <S extends UiKitPayload>(
appId,
value,
blockId,
}),
);
});
});
export { useUIKitHandleAction };

Loading…
Cancel
Save