Skip to content

Instantly share code, notes, and snippets.

@salvar-labs
Created February 4, 2021 23:09
Show Gist options
  • Select an option

  • Save salvar-labs/626e5c31cdd41b7c195cb63646859ed4 to your computer and use it in GitHub Desktop.

Select an option

Save salvar-labs/626e5c31cdd41b7c195cb63646859ed4 to your computer and use it in GitHub Desktop.
React Classic Function Binding
/**
* 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