-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d49869
commit c2c250f
Showing
4 changed files
with
40 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
Check failure on line 2 in src/App.tsx GitHub Actions / run_linter (20.x)
|
||
|
||
export const App: React.FC = () => ( | ||
<div className="App"> | ||
<p className="App__message">The last pressed key is [Enter]</p> | ||
</div> | ||
); | ||
export class App extends React.Component { | ||
state = { | ||
message: 'Nothing was pressed yet', | ||
}; | ||
|
||
handleKeyUp = (event: KeyboardEvent) => { | ||
this.setState({ message: `The last pressed key is [${event.key}]` }); | ||
}; | ||
|
||
componentDidMount(): void { | ||
document.addEventListener('keyup', this.handleKeyUp); | ||
} | ||
|
||
componentWillUnmount(): void { | ||
document.removeEventListener('keyup', this.handleKeyUp); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="App"> | ||
<p className="App__message">{this.state.message}</p> | ||
</div> | ||
); | ||
} | ||
} |