Answer the question
In order to leave comments, you need to log in
How to handle window or document event in react js?
There is a small code in react js
class Task extends React.Component {
constructor(props) {
super(props);
this.state = {
keyDown: false, // по умолчанию, игра остановлена
}
}
editkeyDown = () =>{
this.setState({keyDown: this.state.keyDown ? false : true})
}
render() {
return (
<div id="map" className="Box">
</div>
)
}
}
const app = document.getElementById("example");
ReactDOM.render(
<div className="field">
<Task />
</div>,
app
);
$(window).on("keydown", function(event){
console.log(event);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question