react-international-phone
react-international-phone copied to clipboard
feat: Allow passing custom component to flags prop #203
What has been done
A custom component for rendering flags can now be passed to flags prop instead of list of image URLs enabling support for more use cases. Change is not breaking.
More detailed use case described in #203
Checklist before requesting a review
- [x] I have read the contributing doc before submitting this PR.
- [x] Commit titles correspond to the convention.
- [x] I have performed a self-review of my code.
- [x] Tests for the changes have been added (for bug fixes/features).
- [x] Docs have been added / updated (for bug fixes / features).
Example
const CustomFlag = ({
iso2,
style,
className,
}}) => {
return (
<img
src={`/flags/${iso2}.svg`}
style={{ ...style, width: '24px', height: '24px' }}
className={className}
/>
);
};
<PhoneInput flags={CustomFlag} />