Skip to content

Instantly share code, notes, and snippets.

@deevis
Created September 20, 2021 19:08
Show Gist options
  • Save deevis/af592a2ad335cfbc5d78cbe995562f0a to your computer and use it in GitHub Desktop.
Save deevis/af592a2ad335cfbc5d78cbe995562f0a to your computer and use it in GitHub Desktop.
Build a histogram of React hook usage in a project
for effect in useState useEffect useContext useReducer useCallback useMemo useRef useImperativeHandle useLayoutEffect useDebugValue; do RESULT=`find client/src -iname "*.js" | xargs grep -s -E "import React.*use.*from" | grep $effect | wc -l`; echo "$RESULT $effect"; done | sort -n -r
# 166 useState
# 128 useEffect
# 23 useCallback
# 8 useRef
# 1 useReducer
# 1 useContext
# 0 useMemo
# 0 useLayoutEffect
# 0 useImperativeHandle
# 0 useDebugValue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment