All Projects → stevenpersia → Captain Hook

stevenpersia / Captain Hook

Licence: mit
Custom React hooks for your project.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Captain Hook

use-tiny-state-machine
A tiny (~700 bytes) react hook to help you write finite state machines
Stars: ✭ 37 (-87.58%)
Mutual labels:  hooks
Ddetours
Delphi Detours Library
Stars: ✭ 256 (-14.09%)
Mutual labels:  hooks
React Fetch Hook
React hook for conveniently use Fetch API
Stars: ✭ 285 (-4.36%)
Mutual labels:  hooks
Twenty48
A modified clone of the puzzle game 2048, built in react/typescript!
Stars: ✭ 31 (-89.6%)
Mutual labels:  hooks
MouseInjectDetection
Simple method of checking whether or not mouse movement or buttons (<windows 10) are injected
Stars: ✭ 29 (-90.27%)
Mutual labels:  hooks
Pre Commit Golang
Golang hooks for pre-commit
Stars: ✭ 261 (-12.42%)
Mutual labels:  hooks
revery-graphql-hooks
A library for easy handling of GraphQL with hooks for Revery
Stars: ✭ 34 (-88.59%)
Mutual labels:  hooks
Googlekeepclone
A clone of Google Keep with its original Material Design aesthetics
Stars: ✭ 281 (-5.7%)
Mutual labels:  hooks
mantine
React components library with native dark theme support
Stars: ✭ 4,390 (+1373.15%)
Mutual labels:  hooks
Radioactive State
☢ Make Your React App Truly Reactive!
Stars: ✭ 273 (-8.39%)
Mutual labels:  hooks
react-movies-finder
React Movies finder is a React app to search movies and series using redux, redux-thunk, React Hooks, and Material UI
Stars: ✭ 27 (-90.94%)
Mutual labels:  hooks
meteor-method-hooks
atmospherejs.com/seba/method-hooks
Stars: ✭ 24 (-91.95%)
Mutual labels:  hooks
Use Event Listener
A custom React Hook that provides a declarative useEventListener
Stars: ✭ 265 (-11.07%)
Mutual labels:  hooks
graphire
An unopinionated react graph visualization library.
Stars: ✭ 256 (-14.09%)
Mutual labels:  hooks
Ice
🚀 The Progressive App Framework Based On React(基于 React 的渐进式应用框架)
Stars: ✭ 16,961 (+5591.61%)
Mutual labels:  hooks
hookr
PHP action and filter hook system
Stars: ✭ 39 (-86.91%)
Mutual labels:  hooks
Usehooks
Easy to understand React Hook code recipes
Stars: ✭ 3,075 (+931.88%)
Mutual labels:  hooks
Trousers
hooks-first CSS-in-JS library, focused on semantics and runtime performance
Stars: ✭ 295 (-1.01%)
Mutual labels:  hooks
Swr
React Hooks for data fetching
Stars: ✭ 20,348 (+6728.19%)
Mutual labels:  hooks
React Wait
Complex Loader Management Hook for React Applications
Stars: ✭ 268 (-10.07%)
Mutual labels:  hooks

Captain hook

captain hook

Overview

Here is a modest list of hooks that I use every day. I will add more in the next few days, keep watching. And if you have some good hooks I would love to add them. So feel free to open a pull request.

Hooks

useFetch - View code

Useful hook if you want to fetch data.

How to use

Import hook :

import useFetch from "hooks/useFetch";

Then use like this :

const { response, errors } = useFetch("https://github.com/stevenpersia/");

Demo

View in CodeSandbox


useFullScreen - View code

Useful hook if you want to fullscreen an element of your page.

How to use

Import hook :

import useFullScreen from "hooks/useFullScreen";

Add :

const { elementFS, triggerFS, exitFS, isFS } = useFullScreen();

Then use like this :

<div ref={elementFS}>I want to fullscreen this div.</div>
<button onClick={triggerFS}>Trigger fullscreen</button>
<button onClick={exitFS}>Exit fullscreen</button>

Check if fullscreen is triggered :

console.log(isFS);

Demo

View in CodeSandbox


useHover - View code

Useful hook if you want to detect when the mouse is hovering an element.

How to use

Import hook :

import useHover from "hooks/useHover";

Add :

const [hoverRef, isHovered] = useHover();

Then use like this :

<div ref={hoverRef}>{isHovered ? "Hovered !" : "Hover me !"}</div>

Demo

View in CodeSandbox


useKeyPress - View code

Useful hook if you want to detect when user is pressing a specific key.

How to use

Import hook :

import useKeyPress from "hooks/useKeyPress";

Then use like this :

const hKeyPressed = useKeyPress("h");

console.log(hKeyPressed && "Hello !");
// → Hello !

Demo

View in CodeSandbox


useSlug - View code

Useful hook if you want to slug content for urls.

How to use

Import hook :

import useSlug from "hooks/useSlug";

Then use like this :

useSlug("Omégà! Pèlô Fùll");
// → omega-pelo-full

Demo

View in CodeSandbox


useSwap - View code

Useful hook if you want to swap the keys and values of a given object.

How to use

Import hook :

import useSwap from "hooks/useSwap";

Then use like this :

useSwap({ name: "A", init: "bootstrap" });
// → {A: "name", bootstrap: "init"}

Demo

View in CodeSandbox


useTitle - View code

Useful hook if you want to set a specific title to page.

How to use

Import hook :

import useTitle from "hooks/useTitle";

Then use like this :

useTitle("My title");

Demo

View in CodeSandbox


useToggle - View code

Useful hook if you want display/hide something with toggle.

How to use

Import hook :

import useToggle from "hooks/useToggle";

Then use like this :

const [open, toggle] = useToggle(false);

<Button onClick={toggle}>Show filters</Button>;

{
	open && <Filters />;
}

Demo

View in CodeSandbox


useEventListener - View code

Useful hook if you want to create an event handler.

How to use

Import hook :

import useEventListener from "hooks/useEventListener";

Then use like this :

const [coords, setCoords] = useState({ x: 0, y: 0 });

useEventListener("mousemove", ({ clientX, clientY }) =>
	setCoords({ x: clientX, y: clientY })
);

console.log(coords);

Demo

View in CodeSandbox


useInfiniteScroll - View code

Useful hook if you want to add the infinite scroll feature to your website.

How to use

Import hook :

import useInfiniteScroll from "hooks/useInfiniteScroll";

Then use like this :

const [isFetching, setIsFetching] = useInfiniteScroll(fetchData);

const fetchData = () => {
	// ...
};

Demo

View in CodeSandbox


useFavicon - View code

Useful hook if you want to set a specific favicon to the page.

How to use

Import hook :

import useFavicon from "hooks/useFavicon";

Then use like this :

useFavicon("/path/image.png", "image/png");

Demo

View in CodeSandbox


Star, Fork, Clone & Contribute

Feel free to contribute on this repository. If my work helps you, please give me back with a star. This means a lot to me and keeps me going!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].