DEV Community

Discussion on: Introduction to React.memo, useMemo and useCallback

Collapse
 
trangchongcheng profile image
cucheng

Hi Huy,
Do you think about React.memo must used together with useCallback?
Because the component wrap by React.memo always re-render with props is reference type.

Collapse
 
dinhhuyams profile image
TrinhDinhHuy

If you pass something with reference type such as function then YES we can use useCallback to prevent the re-render. Otherwise it's not necessary if you pass primitive values (boolean, string, ..)