Skip to content

Commit

Permalink
change component type
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiiaHombalevska committed May 30, 2024
1 parent a5049d9 commit dd0556b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ type Props = {
pressedKey: string;
};

export class App extends React.Component<Props> {
state = {
export class App extends React.Component {
state: Props = {
pressedKey: 'Nothing was pressed yet',
}
};

handleKeyPressed = ((event: KeyboardEvent) => {
this.setState({ pressedKey: 'The last pressed key is ' + '[' + event.key + ']' });
});
handleKeyPressed = (event: KeyboardEvent) => {
this.setState({
pressedKey: 'The last pressed key is ' + '[' + event.key + ']',
});
};

componentDidMount() {
window.document.addEventListener('keyup', this.handleKeyPressed);
};
}

componentWillUnmount() {
window.document.removeEventListener('keyup', this.handleKeyPressed);
Expand Down

0 comments on commit dd0556b

Please sign in to comment.