I have this function and pass it to component but after useMemo wrapper it says me that modalComponentsData is not function
const modalComponentsData = useMemo(() => {
return [
{ name: 'name', placeholder: 'Company name' },
]
}, [])
useMemo
calls the function it gets to produce the value. You need useCallback
.
const modalComponentsData = useCallback(() => {
return [
{ name: 'name', placeholder: 'Company name' },
]
}, [])
Or
const modalComponentsData = useMemo(() => () => {
return [
{ name: 'name', placeholder: 'Company name' },
]
}, [])
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments