import React from 'react';
class App extends React.Component {
getTime() {
return new Date().toLocaleDateString();
}
state = { time: null };
render() {
return (
<div htmlFor="search">
<label className="search" htmlFor="username">Name Please: </label>
<input id="username" type="text" />
<button style={{backgroundColor: 'blue', color: 'white'}}> Submit </button>
<p>{getTime()}</p>
</div>
)
}
}
export default App;
I've been trying to get the time and display it in React but I keep getting errors. Line 16:11: 'getTime' is not defined no-undef But I've been doing just as tutorial told me to. What am I doing wrong?
this.getTime()?