So I am really lost on this one. I use ubuntu, and nvm for node. I even removed the version of node that was installed with apt to make sure
node --version
> v10.10.0
npm --version
> 6.4.1
So I create-react-app
and use this simple code
import React from 'react'
import ReactDOM from 'react-dom'
class App extends React.Component
{
componentDidMount()
{
const a = setTimeout(() => {return}, 5000)
console.log("a = ", a)
}
render()
{
return (
<div>
hello
</div>)
}
}
ReactDOM.render(<App />, document.getElementById('root'))
Then I npm start
. When accessing the page, the console displays a number (a = 4). However https://nodejs.org/api/timers.html states that setTimeout
should return a Timeout object, not an id.
This is a problem to me because I wish to call refresh
on the stored variable, and cannot right now (I have found no ways of retrieving the timeout object based on the id).
Is it a react problem that is not using the correct node version? Or is it a regression? I have tried the 10.2 version as well without luck.
Thanks in advance!