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

TASK: Convert Badge to Typescript #2106

Closed
wants to merge 1 commit into from

Conversation

mstruebing
Copy link
Contributor

let's see if this works

let's see if this works
import React from 'react';
import mergeClassNames from 'classnames';

export interface BadgeProps {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Somehow I want to have this called Props, but I did it because of consistency

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's call it Props then. Also why do we export it? Let's not export until we actually need it.

/**
* An optional `className` to attach to the wrapper.
*/
className: string | null | undefined;
Copy link
Contributor Author

@mstruebing mstruebing Aug 26, 2018

Choose a reason for hiding this comment

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

This feels a bit weird, wouldn't it be enough to check for two of these values in the future? (null OR undefined)

Copy link
Contributor

Choose a reason for hiding this comment

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

For some reason when I tried className?: string (which is the equivalent to className: string | undefined) it complained about typo error, because themr was providing it as a possible return type... but when I'm trying it out locally it works just fine... So try className?: string and see if it complains.

Copy link
Contributor

@dimaip dimaip left a comment

Choose a reason for hiding this comment

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

Hey, feels great to have somebody else besides me digging into the topic!!
I left a few comments. Could you try to adjust my Label component to the changes that you'd make to Badge, for the sake of consistency (i.e. convert to class, className?, etc)?

/**
* An optional `className` to attach to the wrapper.
*/
className: string | null | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

For some reason when I tried className?: string (which is the equivalent to className: string | undefined) it complained about typo error, because themr was providing it as a possible return type... but when I'm trying it out locally it works just fine... So try className?: string and see if it complains.

import React from 'react';
import mergeClassNames from 'classnames';

export interface BadgeProps {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's call it Props then. Also why do we export it? Let's not export until we actually need it.

};
}

const Badge: React.SFC<BadgeProps> = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Since I fixed the themr package, it's now possible to use proper react classes again. Could you give it a try, since before we have agreed not to use SFC's?

*/
theme: PropTypes.shape({
badge: PropTypes.string
}).isRequired
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was the theme required before? I think it should indeed be optional.

@dimaip dimaip mentioned this pull request Aug 30, 2018
6 tasks
@mstruebing
Copy link
Contributor Author

#2128 makes this obsolete, therefore I close this.

@mstruebing mstruebing closed this Sep 17, 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.

2 participants