mori icon indicating copy to clipboard operation
mori copied to clipboard

React propTypes

Open farism opened this issue 8 years ago • 2 comments

I was looking for a way to validate mori types with React, but I couldn't find a library. So I threw together a package to deal with mori propTypes:

https://github.com/farism/react-mori-proptypes

farism avatar Jun 25 '16 00:06 farism

Would be great if in the future, Mori provided type definitions (for Typescript, Flow), which would allow type-checking across any interface (React, etc).

Using Flow as an example, in React's case, you could then include the required Mori types in a type alias (along with other native JS data types), which would allow you to validate all props in an elegant interface. E.g:

import type {HashMap} from 'mori/type-defs';

type Props = {
  handleCookieBannerClick: Function,
  whatever: string,
  hashMap: HashMap
};

const MyComponent = (props: Props) => (
  ...
);

jameshopkins avatar Jun 25 '16 15:06 jameshopkins

Could really do with flow type definitions 👍 @jameshopkins would be awesome cakes!

jonsharratt avatar Jun 25 '16 15:06 jonsharratt