Consider i got such example:
import React, { useMemo, useCallback } from 'react'
const Hello = (props) => {
const { firstName, lastName } = props
const fullName = useMemo(() => `${firstName} ${lastName}`, [firstName, lastName])
const sayHello = useCallback(() => {
console.log(`Hello, ${fullName}`)
}, [fullName])
return (
// ...
)
}
export default Hello
Basically i have a component called Hello, and it receives two props firstName and lastName, then i need to calculate fullName based on those two props and has a function sayHello() uses fullName to do something
So my question is: In here is it necessary to use useMemo() and useCallback() for performance optimization? It seems like its kind of overuse of useMemo() and useCallback() for just a little benefit, and i am not sure if this might cause potential side effects?