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

Console warning: prop amPm is required but not set in Hour12Input #24

Closed
emilyuhde opened this issue May 23, 2019 · 6 comments
Closed

Comments

@emilyuhde
Copy link
Contributor

emilyuhde commented May 23, 2019

When using the TimePicker in dev mode, I'm seeing a console warning.

Warning: Failed prop type: The prop amPm is marked as required in Hour12Input, but its value is null. in Hour12Input (created by TimeInput) in TimeInput (created by TimePicker) in div (created by TimePicker)

I only seem to be seeing this warning when I use hooks to manage the state of the TimePicker component: https://gist.github.com/emilyuhde/ded5df5a5b54baeb981403148b9c892a

I don't see the warning when I use a stateful class: https://gist.github.com/emilyuhde/8275a185ca2ca649a30dc3fb6df9be88

@emilyuhde
Copy link
Contributor Author

I think I see the issue, the react dependency is "react": "^16.7.0". Are there plans to update the dependency to 16.8.x soon?

@wojtekmaj
Copy link
Owner

^16.7.0 signifies compatibility with >=16.7.0; <17.0.0, so with 16.8.0, too. I don't think that is the cause!

@wojtekmaj
Copy link
Owner

Hmmmm, I tested your code and I don't see the warning you're seeing. The only thing I see is that you use useState() without default prop, which causes it to be undefined initially, which is not the case in your class component. So maybe that's the problem?

@emilyuhde
Copy link
Contributor Author

Thanks for looking at this. I was looking at this issue some more yesterday and I think I figured out what's actually causing it. If I initialize the value to null, and the TimePicker is in 12 hour format, that seems to be what's causing the console warning to appear. I think the use of a class component with state vs using hooks was just a red herring and isn't actually causing an issue. That's why I closed this issue and created #31 since that console warning isn't wrong, it's just annoying when I want to intentionally initialize the value to null so that the TimePicker will display the placeholder --:-- -- state.

@yaniiv
Copy link

yaniiv commented Jun 28, 2019

+1, having the exact same issue as emily. I can confirm that it has to do with initializing the value to null. Not a big issue, but it would be helpful to add a blurb in the readme!

@wojtekmaj
Copy link
Owner

@yantonsoup This has already been fixed and will land in the next release.

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

No branches or pull requests

3 participants