Quantcast
Channel: React utility function to bind this keyword - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by Kishan Jaiswal for React utility function to bind this keyword

import { handleKeyPress } from "../util/index" class Input extends Component { constructor(props) { super(props) this.state = { isOpen: false } } render() { return <input onKeyPress={(e) =>...

View Article


Answer by Kubilay Kiymaci for React utility function to bind this keyword

if you don't want to writing bind in the constructor, you can write your event with arrow function. render() return <input onKeyPress = {() => this.handleOnKeyPress() }/> } After that you can...

View Article


React utility function to bind this keyword

I have a utility function, but this is undefined even I bind it in my react component: /util/index: export const handleKeyPress = e =>{ console.log(this) } /component/input/: import...

View Article
Browsing latest articles
Browse All 3 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>