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

[TextField] value propType #6091

Merged
merged 2 commits into from
Feb 10, 2017
Merged
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 src/Input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default class Input extends Component {
/**
* The input value, required for a controlled component.
*/
value: PropTypes.string,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
Copy link
Member

Choose a reason for hiding this comment

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

What about value: PropTypes.any,?

Copy link
Author

Choose a reason for hiding this comment

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

I am fine with any since it lets me pass in a number without errors....but does it make sense to allow arrays and objects and functions for an input? Or is it better that we just check something is sent in, and if your passing non scalar values that's on you? I'd be glad to change this to any just let me know your thoughts on allowing non scalar values

Copy link
Member

Choose a reason for hiding this comment

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

but does it make sense to allow arrays and objects and functions for an input?

Good point, I'm pretty convinced people we ask for it. I could ask the same question, does it makes sense to provide a number and not a string? People will try to provide boolean too.

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't that be:

import propTypes from '../utils/propTypes';
[...]
value: propTypes.stringOrNumber,

?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I didn't know we had stringOrNumber. I would rather remove that helper.
I don't think that this abstraction add much value.

Copy link
Member

Choose a reason for hiding this comment

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

It's only used in one other place, so easily done. I guess it will go away with next...

};

static defaultProps = {
Expand Down