Metadata marked as required but gets undefined
kirkegaard opened this issue Β· comments
When using import PhoneInputWithCountry from "react-phone-number-input/react-hook-form";
im getting a warning:
![Screenshot 2023-08-07 at 14 24 29](https://private-user-images.githubusercontent.com/43752/258800148-80180bf3-bfb4-470d-8a4b-aa63c915c1a3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI0NzI2NTksIm5iZiI6MTcyMjQ3MjM1OSwicGF0aCI6Ii80Mzc1Mi8yNTg4MDAxNDgtODAxODBiZjMtYmZiNC00NzBkLThhNGItYWE2M2M5MTVjMWEzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODAxVDAwMzIzOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk5M2ZmZWY5YmI5ZGMxZDY4MjQyOGE0MDcwM2Q3YWYxNTFjY2ZlZTQwODY4ODUzNTlkMWQ5NDA3NGVjYzcwNzQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.sEKgYQKuG8vRdKLZRCcs3Hiw0JfnRJEqP8DynJeQoW0)
$ yarn why react-hook-form
yarn why v1.22.19
[1/4] π€ Why do we have the module "react-hook-form"...?
[2/4] π Initialising dependency graph...
[3/4] π Finding dependency...
[4/4] π‘ Calculating file sizes...
=> Found "react-hook-form@7.45.4"
info Has been hoisted to "react-hook-form"
info This module exists because it's specified in "dependencies".
info Disk size without dependencies: "1.91MB"
info Disk size with unique dependencies: "1.91MB"
info Disk size with transitive dependencies: "1.91MB"
info Number of shared dependencies: 0
β¨ Done in 0.17s.
$ yarn why react-phone-number-input
yarn why v1.22.19
[1/4] π€ Why do we have the module "react-phone-number-input"...?
[2/4] π Initialising dependency graph...
[3/4] π Finding dependency...
[4/4] π‘ Calculating file sizes...
=> Found "react-phone-number-input@3.3.1"
info Has been hoisted to "react-phone-number-input"
info This module exists because it's specified in "dependencies".
info Disk size without dependencies: "9.73MB"
info Disk size with unique dependencies: "43.2MB"
info Disk size with transitive dependencies: "43.32MB"
info Number of shared dependencies: 9
β¨ Done in 0.35s.
$ yarn why libphonenumber-js
yarn why v1.22.19
[1/4] π€ Why do we have the module "libphonenumber-js"...?
[2/4] π Initialising dependency graph...
[3/4] π Finding dependency...
[4/4] π‘ Calculating file sizes...
=> Found "libphonenumber-js@1.10.39"
info Reasons this module exists
- "react-phone-number-input" depends on it
- Hoisted from "react-phone-number-input#libphonenumber-js"
info Disk size without dependencies: "9.84MB"
info Disk size with unique dependencies: "9.84MB"
info Disk size with transitive dependencies: "9.84MB"
info Number of shared dependencies: 0
β¨ Done in 0.18s.
The same problem.
Temporarily fixed this by importing metadata and explicitly assigning it to PhoneInput.
import metadata from 'libphonenumber-js/min/metadata'
...
<PhoneInputWithCountry
international
metadata={metadata}
Experiencing the same as well.
Turns out that the previous refactoring that removed .defaultProps
has left .isRequired
on those props and those .isRequired
statements should've been removed too.
Published react-phone-number-input@3.3.2
.