react18-tools/react-mouse-trail

View on GitHub
examples/nextjs/src/app/button.tsx

Summary

Maintainability
A
0 mins
Test Coverage
"use client";

import { useCallback } from "react";
import { useLoader } from "react18-loaders";
import styles from "./button.module.css";

/** Button to show global loader for 3 sec. */
export default function MyButton() {
  const { setLoading } = useLoader();
  const handleClick = useCallback(() => {
    setLoading(true);
    setTimeout(() => {
      setLoading(false);
    }, 3000);
  }, []);
  return (
    <button onClick={handleClick} className={styles.btn}>
      Show Global Loader for 3 sec
    </button>
  );
}