↧
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 ArticleAnswer 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 ArticleReact 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