Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move 'this' binding to componentWillMount #11

Merged
merged 2 commits into from
Oct 12, 2016

Conversation

maniax89
Copy link
Contributor

Binding of methods should be done during the creation of the object not during the creation of the children components

@@ -12,6 +12,13 @@ export default class Rule extends React.Component {
};
}

componentWillMount() {
this.onFieldChanged = this.onFieldChanged.bind(this);
Copy link
Contributor

@pavanpodila pavanpodila Oct 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing any .bind(), we could also just do this:

onFieldChanged = ()=>{ /* ... */};

this relies on the property-initializer syntax. Note that we have to include this babel-plugin

npm install --save-dev babel-preset-stage-1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@pavanpodila pavanpodila merged commit d3b1905 into react-querybuilder:master Oct 12, 2016
@pavanpodila
Copy link
Contributor

@maniax89 Seeing test failures after the merge. Possibly because of plugin issues or webpack.test is not configured correctly ?

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  SyntaxError: Use of reserved word 'class'
  at lib/QueryBuilder.test.js:19020

@maniax89 maniax89 deleted the binding_methods branch October 12, 2016 21:43
jakeboone02 added a commit that referenced this pull request Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants