@ttoss/hooks
v1.21.13
Published
React hooks.
Downloads
30
Readme
@ttoss/hooks
📚 About
@ttoss/hooks is a easiest way to use Util Hooks in your React application.
🚀 Getting Started
Install @ttoss/hooks
$ yarn add @ttoss/hooks
# or
$ npm install @ttoss/hooks
📄 Examples of use
import React from "react";
import { useScript } from "@ttoss/hooks";
export const Component = () => {
const url = "https://your-domain.com/bundle-api.js";
const { status } = useScript(url);
return <div>{status === "ready" ? "Ok" : "Loading"}</div>;
};
📘 Types
type ScriptStatus = "idle" | "loading" | "ready" | "error";
const useScript: (src: string) => {
status: ScriptStatus;
};