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

chore(Switch): convert Switch to TypeScript #2311

Merged
merged 4 commits into from
Jul 2, 2019

Conversation

tlabaj
Copy link
Contributor

@tlabaj tlabaj commented Jun 20, 2019

#2019

What:

Additional issues:

@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://patternfly-react-pr-2311.surge.sh

/** A callback for when the Switch selection changes. (isChecked, event) => {} */
onChange: PropTypes.func,
onChange?(checked: boolean, event: FormEvent<HTMLInputElement>): void;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use an arrow function so the docs pick this up properly. Like `onChange?: (checked: boolean, event: FormEvent) => void;

'aria-label': ''
};
export class Switch extends React.Component<SwitchProps> {
id = '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this class attribute

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what the purpose of this id is ... is it suppose to be the same as props.id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it instantiates the id when it is generated. And there is no id prop set.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it instantiate it as a defaultProp to getUniqueId()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure. Does it work differently in TS than JS. In JS if you set defaultProp to getUniqueId, if you had more hat one Switch on the page the id's would all be the same? That is why we had it in the constructor before.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like it will set it for all of the name to be the same based off the time. Leave it in the constructor.

Copy link
Contributor

@dlabaj dlabaj left a comment

Choose a reason for hiding this comment

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

Wondering what was the use case for that separate class attribute ID.

'aria-label': ''
};
export class Switch extends React.Component<SwitchProps> {
id = '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what the purpose of this id is ... is it suppose to be the same as props.id?

'aria-label': ''
};
export class Switch extends React.Component<SwitchProps> {
id = '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like it will set it for all of the name to be the same based off the time. Leave it in the constructor.

@redallen redallen merged commit dac87ba into patternfly:master Jul 2, 2019
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.

5 participants