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

Prop types fix #723

Open
wants to merge 1 commit into
base: airship-3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-ui/src/widgets/CategoryWidgetUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ CategoryWidgetUI.propTypes = {
data: PropTypes.arrayOf(
PropTypes.shape({
category: PropTypes.string.isRequired,
value: PropTypes.number.isRequired
value: PropTypes.number
Copy link
Contributor

@neokore neokore Nov 4, 2020

Choose a reason for hiding this comment

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

Here we can use oneOfType and allow number/string/null
After checking the docs again, I see that this is the recommended way for null (plus undefined and so)
I agree with the change.

})
).isRequired,
formatter: PropTypes.func,
Expand Down
5 changes: 3 additions & 2 deletions packages/react-ui/src/widgets/FormulaWidgetUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ FormulaWidgetUI.defaultProps = {
FormulaWidgetUI.propTypes = {
data: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.shape({
value: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]).isRequired,
unit: PropTypes.string.isRequired
]),
unit: PropTypes.string
Copy link
Contributor

@neokore neokore Nov 4, 2020

Choose a reason for hiding this comment

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

same here, until we want to allow empty units using this format, in that case, ok
Maybe here I'll rather improve the way to paint the unit, to skip it in case of not existing, because right now it could leave an empty space before the value.

})
]),
formatter: PropTypes.func
Expand Down