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

[TextField] value propType #6091

merged 2 commits into from
Feb 10, 2017

Conversation

neilholcomb
Copy link

Allow Input component to except a number or a string as its value prop...instead of just string

  • PR has tests / docs demo, and is linted.
  • Commit and PR titles begin with [ComponentName], and are in imperative form: "[Component] Fix leaky abstraction".
  • Description explains the issue / use-case resolved, and auto-closes the related issue(s) (http://tr.im/vFqem).

@@ -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...

@oliviertassinari oliviertassinari added the component: text field This is the name of the generic UI component, not the React module! label Feb 9, 2017
@oliviertassinari oliviertassinari changed the title Next [TextField] value propType Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: text field This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants