setTimeout function does not display HTML after function ends
You should not write code like that in react. The setTimeout
returns:
The returned timeoutID is a positive integer value which identifies the timer created by the call to setTimeout(). T
and not the JSX which you returned from callback. But even if it did asynchronously return the JSX which you return from callback, you won't see the new content on the screen. To change UI in react you must change a state variable using setState
which will cause a re render. Also render is not the place to call setState
. You can call setState
in useEffect
for example.