All Projects → kyleshevlin → use-debugger-hooks

kyleshevlin / use-debugger-hooks

Licence: MIT license
A small package of custom React hooks that are useful for debugging changes in React hook dependencies across renders

Programming Languages

typescript
32286 projects
HTML
75241 projects

Projects that are alternatives of or similar to use-debugger-hooks

Makin
makin - reveal anti-debugging and anti-VM tricks [This project is not maintained anymore]
Stars: ✭ 645 (+1365.91%)
Mutual labels:  debugging, hooks
react-drag
A drag and drop platform based on sortable.js front-end visualization. 一个基于sortable.js的前端可视化搭建的拖拽平台,ui组件采用antd-mobile.通过umi脚手架构建.技术栈采用dva+hooks+umi+antd-mobile+sortable.js+react-color.
Stars: ✭ 51 (+15.91%)
Mutual labels:  hooks
husky-elixir
🐶 Git hooks made easy
Stars: ✭ 47 (+6.82%)
Mutual labels:  hooks
deno-debug
Debugging utility for deno. Ported from https://npmjs.com/debug
Stars: ✭ 15 (-65.91%)
Mutual labels:  debugging
use-elapsed-time
React hook to measure elapsed time using requestAnimationFrame
Stars: ✭ 42 (-4.55%)
Mutual labels:  hooks
tacklebox
🎣React UX components for handling common interactions
Stars: ✭ 15 (-65.91%)
Mutual labels:  hooks
use-detect-print
A react hook to detect when a page is being printed
Stars: ✭ 55 (+25%)
Mutual labels:  hooks
gha
🔧 Test your GitHub Actions workflow locally.
Stars: ✭ 53 (+20.45%)
Mutual labels:  debugging
preact-urql
Preact bindings for urql
Stars: ✭ 28 (-36.36%)
Mutual labels:  hooks
architectury-api
An intermediary api aimed at easing development of multiplatform mods.
Stars: ✭ 139 (+215.91%)
Mutual labels:  hooks
feathers-shallow-populate
Feathersjs populate relational data
Stars: ✭ 21 (-52.27%)
Mutual labels:  hooks
react-hook-sticky
react hook sticky
Stars: ✭ 19 (-56.82%)
Mutual labels:  hooks
git-templates
Templates / Hooks for Your Git Repositories
Stars: ✭ 30 (-31.82%)
Mutual labels:  hooks
transition-hook
☄️ An extremely light-weight react transition animation hook which is simpler and easier to use than react-transition-group
Stars: ✭ 250 (+468.18%)
Mutual labels:  hooks
wagmi
React Hooks for Ethereum
Stars: ✭ 1,691 (+3743.18%)
Mutual labels:  hooks
react-supabase
React Hooks library for Supabase
Stars: ✭ 168 (+281.82%)
Mutual labels:  hooks
entangle
Global state management tool for react hooks inspired by RecoilJS and Jotai using proxies.
Stars: ✭ 26 (-40.91%)
Mutual labels:  hooks
vscode-react-javascript-snippets
Extension for React/Javascript snippets with search supporting ES7+ and babel features
Stars: ✭ 782 (+1677.27%)
Mutual labels:  hooks
eventrix
Open-source, Predictable, Scaling JavaScript library for state managing and centralizing application global state. State manage system for react apps.
Stars: ✭ 35 (-20.45%)
Mutual labels:  hooks
hooks
A DLL that performs IAT hooking
Stars: ✭ 21 (-52.27%)
Mutual labels:  hooks

use-debugger-hooks

This is a package of custom React hooks that are useful for debugging dependency changes between renders. Most act as drop in replacements for their React hook counterpart. The available hooks include.

  • useLogChanges
  • useCallbackDebugger
  • useEffectDebugger
  • useLayoutEffectDebugger
  • useMemoDebugger

Installation

npm install use-debugger-hooks

Usage

Most of these hooks are drop in replacements for their React hook counterpart. They have the same API, but make use of useLogChanges under the hood to log out changes to your browser's console.

useLogChanges will track a value across renders, logging out any changes that occur.

function Parent(props) {
  useLogChanges(props);

  return <Child {...props} />;
}

Any time that Parent rerenders, any changes to props will be logged to the console.

The other hooks in this library use useLogChanges to track values in the dependencies array. If a dependency changes across renders, it will be logged out to the console.

Say you have a useEffect hook running more often than you expect and you want to see which dependency is causing that to happen. Replace useEffect with useEffectDebugger and then see the changes in the browser's console.

// Problematic effect
useEffect(() => {
  someEffectWithDeps(dep1, dep2, dep3);
}, [dep1, dep2, dep3]);

// Add debugging to log out dependency changes
import { useEffectDebugger } from 'use-debugger-hooks';

useEffectDebugger(() => {
  someEffectWithDeps(dep1, dep2, dep3);
}, [dep1, dep2, dep3]);

Now you'll be able to see which dependency is changing too often and be able to fix the problem.

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].