Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@pwolaq
Copy link
Contributor

@pwolaq pwolaq commented Oct 24, 2018

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.

@pwolaq pwolaq force-pushed the replace-multiple-binds branch from 6836904 to 821eee3 Compare October 24, 2018 20:42
private onScroll = (e: React.UIEvent<HTMLElement>) => {
const { bodyWidth, bodyHeight } = this.props.layout;
const { viewportWidth, viewportHeight } = this.state;
var target = e.target as Element;
Copy link
Collaborator

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?

Copy link
Contributor Author

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 :) ).

Copy link
Collaborator

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 = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

<3

timeString: ""
};
}
state = {
Copy link
Collaborator

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.

Copy link
Collaborator

@adrianmroz adrianmroz left a comment

Choose a reason for hiding this comment

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

Great work!

@adrianmroz adrianmroz merged commit 33b0fd0 into allegro:master Oct 26, 2018
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.

Avoid using bind multiple times

2 participants