Skip to content

TypeError in useAction Hook: finally is not a function #7

@ramyodev

Description

@ramyodev

Issue Summary

A TypeError occurs within the useAction hook of the Blinks SDK when attempting to use a finally block after a promise chain.

Steps to Reproduce

  1. Integrate the Blinks SDK within a React component using the useAction hook.
  2. Trigger the component that executes the useAction hook.
  3. Observe the console for any errors during the action fetching process.

Error Message

ERROR TypeError: _chunk3VHJSHHRcjs.Action.fetch(a(...)", e); setAction(null); }).finally is not a function (it is undefined)

Code Snippet

useEffect(() => {
  setIsLoading(true);
  if (!isRegistryLoaded || !actionApiUrl) {
    return;
  }
  let ignore = false;
  _chunk3VHJSHHRcjs.Action.fetch(actionApiUrl, void 0, supportStrategy).then((action2) => {
    if (ignore) {
      return;
    }
    setAction(action2);
  }).catch((e) => {
    console.error("[@dialectlabs/blinks] Failed to fetch action", e);
    setAction(null);
  }).finally(() => {
    if (!ignore) {
      setIsLoading(false);
    }
  });
  return () => {
    ignore = true;
  };
}, [actionApiUrl, isRegistryLoaded]);

Suggested Fix

Removing the finally block resolves the error and allows the component to function, but this is not ideal. A better fix would be to ensure that the Promise implementation in the environment includes finally or to add a polyfill.

Environment

  • React Native version: 0.74.3
  • react-native-picker-select version: ^9.1.3
  • @dialectlabs/blinks version: ^0.8.0
  • @dialectlabs/blinks-react-native version: ^0.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions