Created
February 4, 2021 23:09
-
-
Save salvar-labs/626e5c31cdd41b7c195cb63646859ed4 to your computer and use it in GitHub Desktop.
React Classic Function Binding
This file contains hidden or 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
| /** | |
| * Classic function binding | |
| */ | |
| import React from 'react'; | |
| export default class CustomComponent extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.classicBindingFunction = this.classicBindingFunction.bind(this); | |
| } | |
| classicBindingFunction() { | |
| console.log("This function needs to be bound in the constructor.") | |
| } | |
| render() { | |
| // ... | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment