Custom Hook
↔ user defined Hook to consume Library Hook & reuse stateful logic
aka Custom-Hooks
usehooks.com
collection of useful custom hooks/snippets
useToggle()
Custom Hook to flip boolean
Param
useRouter()
Custom Hook to combine useParams()
, useLocation()
, useHistory()
& useRouteMatch()
useEventListener
usePrevious()
Custom Hook to get previous value of props
or state
useOnClickOutside()
Custom Hook to detect click outside a specific element
useAsync()
async
Custom Hook to return value, error, status of Data Fetch
useEventListener()
Custom Hook to Refactor event listeners
useWhyDidYouUpdate()
Custom Hook to debug which prop change trigger re-render
Source: usehooks.com/useWhyDidYouUpdate/
useDarkMode()
Custom Hook to handle dark mode toggle, req useLocalStorage()
& useMedia()
useLocalStorage()
Custom Hook to
useScript()
Custom Hook to Dynamically load external Script
useOnScreen()
Custom Hook to return boolean to check if node (as ref) is visible on Viewport; Abstracts Intersection Observer API
Web API
useAuth()
async
Custom Hook to get Auth state from Backend/Online API
References
useToggle()
↔ Custom Hook to flipboolean
ParamuseRouter()
↔ Custom Hook to combineuseParams()
,useLocation()
,useHistory()
&useRouteMatch()
useAuth()
↔async
Custom Hook to get Auth state from Backend/Online APIusePrevious()
↔ Custom Hook to get previous value ofprops
or stateuseOnClickOutside()
↔ Custom Hook to detect click outside a specific elementuseAsync()
↔async
Custom Hook to return value, error, status of Data FetchuseEventListener()
↔ Custom Hook to Refactor event listenersuseWhyDidYouUpdate()
↔ Custom Hook to debug which prop change trigger re-renderuseDarkMode()
↔ Custom Hook to handle dark mode toggle, requseLocalStorage()
&useMedia()
useScript()
↔ Custom Hook to Dynamically load external ScriptuseTypedSelector()
↔ Custom Hook var ofuseSelector()
with fixed type annotationsuseActions()
↔ Custom Hook to bind actionCreators to Dispatch