useRef(initialValue) is just useState({ current: initialValue })[0], so you get that one for free. useCallback(callback, dependencies) is merely a shorthand for useMemo(() => callback, dependencies). Also, you forgot useLayoutEffect in your list.
I mostly use useState, useRef and useEffect. If need be, I'll use useContext, but I try to avoid useCallback (you can directly use a Dispatch from useState as a callback in most occassions and handle the result in an effect). I also mostly refrain from using useReducer, as it is meant to provide an elegant abstraction of complex logic - and one should always simplify logic as much as possible before abstracting it into code.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
useRef(initialValue)
is justuseState({ current: initialValue })[0]
, so you get that one for free.useCallback(callback, dependencies)
is merely a shorthand foruseMemo(() => callback, dependencies)
. Also, you forgotuseLayoutEffect
in your list.I mostly use
useState
,useRef
anduseEffect
. If need be, I'll useuseContext
, but I try to avoiduseCallback
(you can directly use a Dispatch from useState as a callback in most occassions and handle the result in an effect). I also mostly refrain from usinguseReducer
, as it is meant to provide an elegant abstraction of complex logic - and one should always simplify logic as much as possible before abstracting it into code.