swannodette / mori

ClojureScript's persistent data structures and supporting API from the comfort of vanilla JavaScript

Home Page:http://swannodette.github.io/mori

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React propTypes

farism opened this issue · 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

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) => (
  ...
);

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