-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
Conversation
let's see if this works
import React from 'react'; | ||
import mergeClassNames from 'classnames'; | ||
|
||
export interface BadgeProps { |
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.
Somehow I want to have this called Props, but I did it because of consistency
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.
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; |
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.
This feels a bit weird, wouldn't it be enough to check for two of these values in the future? (null OR undefined)
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.
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.
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.
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; |
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.
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 { |
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.
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> = ({ |
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.
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 |
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.
Why was the theme required before? I think it should indeed be optional.
#2128 makes this obsolete, therefore I close this. |
let's see if this works