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

jsx-no-bind circumventable via Short-Circuit Evaluation #474

Closed
iilei opened this issue Mar 1, 2016 · 4 comments
Closed

jsx-no-bind circumventable via Short-Circuit Evaluation #474

iilei opened this issue Mar 1, 2016 · 4 comments

Comments

@iilei
Copy link

iilei commented Mar 1, 2016

example code myHandler={true && this.myHandler.bind(this, key)} results in no warnings, while I would expect it to throw error JSX props should not use .bind() react/jsx-no-bind

Is this a bug or am I missing something?

@ljharb
Copy link
Member

ljharb commented Mar 1, 2016

Similarly, I've noticed that const foo = this.whatever.bind(this); and then prop={foo} doesn't seem to warn either.

@iilei
Copy link
Author

iilei commented Mar 1, 2016

@ljharb I assume const foo = this.whatever.bind(this); resides outside of the return block in jsx, right? I don't think that is related

@ljharb
Copy link
Member

ljharb commented Mar 1, 2016

@iilei yes it is - no functions should be created in the entire render path and passed as props, which is what this rule is attempting to prevent.

@iilei
Copy link
Author

iilei commented Mar 1, 2016

I see ... @petersendidit 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants