solid-use-script
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

solid-use-script

Solid hook to dynamically load an external script.

npm i -S solid-use-script

Usage

import { Switch, Match } from 'solid-js';
import { useScript } from 'solid-use-script';

function App() {
  const [loading, error] = useScript('https://some.api');

  return (
    <Switch fallback={<ApiProvider>...</ApiProvider>}>
      <Match when={loading()}>Loading API...</Match>
      <Match when={error()}>Failed to load API: {error().message}</Match>
    </Switch>
  );
}

Attributes

useScript('https://some.api', { crossorigin: 'anonymous' });

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    1

Package Sidebar

Install

npm i solid-use-script

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

5.93 kB

Total Files

6

Last publish

Collaborators

  • sanich