-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Update <Site> component to use ES6 syntax. #3338
Conversation
classNames = require( 'classnames' ), | ||
noop = require( 'lodash/utility/noop' ); | ||
import React from 'react'; | ||
import classnames from 'classnames'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you avoiding camelCase on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's necessary here.
BTW I got these eslint warning it comes from My suggestion: const setStartToottip = startTooltip => this.setState( { startTooltip } );
return (
<button
className="site__star"
onClick={ this.starSite }
onMouseEnter={ setStartTooltip( true ) }
onMouseLeave={ setStartTooltip( false ) }
// ... |
If we're bothering to work around the warning I'd suggest doing it properly. Basically we don't want to create functions in a render method. One way to fix this would be to add: enableStarTooltip() {
this.setState( { starTooltip: true } );
},
disableStarTooltip() {
this.setState( { starTooltip: false } );
},
render() {
return ( <button onMouseEnter={ this.enableStarTooltip } onMouseLeave={ this.disableStarTooltip } /> );
} |
👍 changes look good to 🚢 after a rebase |
6cefa95
to
1763bc8
Compare
@gwwar Marking this back as Needs Review since I rebased it and added the bound methods to get rid of the JSX-bind linting warnings. |
const site = this.props.site; | ||
sites.toggleStarred( site.ID ); | ||
}, | ||
|
||
renderStar: function() { | ||
enableStarTooltip() { | ||
this.setState( { starTooltip: true } ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
; ?
🚢 after adding in the missing ; |
1763bc8
to
2750965
Compare
@gwwar nice catch! fixed in an amended commit. |
No description provided.