Skip to content

Enhacement to method hook to use react-script-hook #14

@aoloo

Description

@aoloo

I was able to get the link element to load by utilizing react-script-hoo. This implementation simplifies the code and makes it super easy to dynamically load an external script and know when it is loaded.

export function useMethod(opts: IElementClientOptions): IElementClient | null {
  const [loading] = useScript({
    src: 'https://static.methodfi.com/elements/v1/stable/init.js',
    checkForExisting: true,
  });

  // @ts-ignore
  return !loading ? new window.Method(opts) : null;
}

Documentation
https://www.npmjs.com/package/react-script-hook

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