This is a performance question since both ways are working.
I need to update a value according to the existence of another value. So I did the follow:
const value = useMemo(() => (a ? valueB : valueC), [a]);
This is ok and works but I read that the useMemo hook is not recommended for easy functions, so I changed to:
const [value, setValue] = useState()
useEffect(()=> {
a ? setValue(valueB) : setValue(valueC)
}, [a])
What is the more performant way to do that and why? Thanks a lot in advance!