-
Notifications
You must be signed in to change notification settings - Fork 180
Replace multiple binds #206
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
Conversation
6836904 to
821eee3
Compare
| private onScroll = (e: React.UIEvent<HTMLElement>) => { | ||
| const { bodyWidth, bodyHeight } = this.props.layout; | ||
| const { viewportWidth, viewportHeight } = this.state; | ||
| var target = e.target as Element; |
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.
Do we need as Element here if we narrowed type of event?
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.
From what I recall e.target was instance of EventTarget, which resulted in errors.
The main purpose of this PR is to get rid of using bind so I did not want to spend more time on fixing this (as this is my first experience with Typescript :) ).
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.
Sure thing! I'm just writing it down to look into later.
| } | ||
|
|
||
| export class ClearableInput extends React.Component<ClearableInputProps, ClearableInputState> { | ||
| static defaultProps = { |
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.
<3
| timeString: "" | ||
| }; | ||
| } | ||
| state = { |
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.
Missing type of state. Typescript does not always infer type of state field. I wonder why.
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.
Great work!
Resolves #203.
It took me some time but I eventually managed to replaced all instances of
.bind(this)with class property bindings. Additionally I replaced unnecessary constructors in few places with setting state via class property.This change should not break anything, but I had a lot of conflicts to resolve due to today's merges so please review carefully.