react-international-phone icon indicating copy to clipboard operation
react-international-phone copied to clipboard

feat: Allow passing custom component to flags prop #203

Open simonnilsson opened this issue 5 months ago • 1 comments

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} />

simonnilsson avatar Sep 06 '24 12:09 simonnilsson