Skip to content

Conversation

@caub
Copy link

@caub caub commented May 4, 2021

No description provided.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Just adding the propType wouldn’t do anything - the component would have to use it, and we’d need tests and a storybook story.

@caub
Copy link
Author

caub commented May 4, 2021

name is already passed into the component, I can see date in input's attributes, it's just that proptypes was out of sync, and was warning about name as extra prop
for tests, I'll see later if I can, but this looks rather not necessary here

@ljharb
Copy link
Member

ljharb commented May 4, 2021

SingleDatePickerInput never references a name prop, so all this PR currently achieves is removes the correct warning that name is an extra, unused prop.

In order to remove the warning, we'd have to actually use the prop inside SingleDatePickerInput.

@caub
Copy link
Author

caub commented May 4, 2021

Oh correct, sorry, wrong component, fixed

@ljharb
Copy link
Member

ljharb commented May 4, 2021

and which component is using the name prop but lacks the propType? https://github.com/airbnb/react-dates/blob/6c2cb61c5e876fbdac72e6efed49c0bd64f06d6b/src/components/SingleDatePicker.jsx, for example, uses the shape but doesn't use the name prop.

@caub
Copy link
Author

caub commented May 4, 2021

yes SingleDatePicker, the one component I use in https://codesandbox.io/s/react-datepickers-o9fbh?file=/src/Datepicker.js

you can see the warning:

Warning: Failed prop type: withStyles(SingleDatePicker): unknown props found: name, pattern
    at withStyles(SingleDatePicker)

And you can also see that date attribute is passed to the input, so I guess that prop is spread to other components

<input class="css-1fqugce" aria-label="YYYY-MM-DD" type="text" id="date" name="date" placeholder="YYYY-MM-DD" autocomplete="off" required="" aria-describedby="DateInput__screen-reader-message-date" value="2021-05-05">

@ljharb
Copy link
Member

ljharb commented May 4, 2021

It's not, in fact - the name is always the same as the ID: https://github.com/airbnb/react-dates/blob/master/src/components/DateInput.jsx#L229-L230

@caub
Copy link
Author

caub commented May 5, 2021

@ljharb Oh thanks, good to know. I'm not really a fan of those 'opinionated' choices, but I'll do with it. It'd be better I think to allow to pass independently name and id

Let's deal with this choice for now, thanks

@caub caub closed this May 5, 2021
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