I am trying to fetch data during ComponentWillMount
lifecycle in server side using useMemo()
const [text, setText] = useState('hello')
const fakeApiCall = new Promise(resolve => 'world')
useMemo(async () => {
const value = await fakeApiCall
setText(value)
}, [])
Doing this the value for text
will still remain hello
instead of world
. Is it possible to achieve this? Why is this not working?