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

Explicitly clarify naming policy for React event handler methods #598

Open
taion opened this issue Dec 2, 2015 · 5 comments
Open

Explicitly clarify naming policy for React event handler methods #598

taion opened this issue Dec 2, 2015 · 5 comments
Labels

Comments

@taion
Copy link
Contributor

taion commented Dec 2, 2015

The ordering section implies that event handlers should be named onFoo rather than handleFoo per FB examples. Is this an explicit rule? If so, it would be nice to have it listed in either the "naming" or "methods" sections.

@taion
Copy link
Contributor Author

taion commented Feb 1, 2016

Any update?

@kesne
Copy link
Contributor

kesne commented Feb 1, 2016

It's worth noting this was briefly discussed in this PR: #619

@taion
Copy link
Contributor Author

taion commented Feb 1, 2016

Interesting – I think it makes sense to name handlers according to what they do, though; makes it easier to see at a glance what is going on without having to check render(). In other words,

class PokePlayerButton extends React.Component {
  /* ... */

  onClick() {
    this.props.pokePlayer();
  }

  /* ... */
}

Otherwise it's harder to tell what's actually the click handler without looking at the source of render().

@ljharb ljharb added the question label Feb 2, 2016
@taion
Copy link
Contributor Author

taion commented Jul 29, 2016

I'm wondering if there's been any changes here – onFoo, handleFoo, "use an appropriate verb-based clause", or something else, especially given that the rule set still includes sort-comp.

@taion
Copy link
Contributor Author

taion commented Jul 25, 2017

Any updates here?

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

No branches or pull requests

3 participants