react-intl-hooks icon indicating copy to clipboard operation
react-intl-hooks copied to clipboard

Simplify

Open Kepro opened this issue 4 years ago • 4 comments

Hello, just checking code and why not to simple return function from hook? like this

import { useIntl } from 'react-intl';

const useFormatMessage = () => {
  const { formatMessage } = useIntl();
  return formatMessage;
};

export default useFormatMessage;

Kepro avatar Apr 17 '21 11:04 Kepro

Hey!

I think because the types wouldn't show up when you use the library. I'm open to find a better solution for it!

MateoKruk avatar Apr 17 '21 13:04 MateoKruk

@MateoKruk formatMessage is typed, so it will just return that type, no need to create wrapper or re-type it

image

Kepro avatar Apr 19 '21 10:04 Kepro

@Kepro oh, that's great! Maybe I over engineered the first version of the library. Are interested in implementing this change?

MateoKruk avatar Apr 19 '21 12:04 MateoKruk

can do! :)

Kepro avatar Apr 19 '21 16:04 Kepro