Ant-design: PropTypes ColProp for shape of labelCol and wrapperCol Props for grid

Created on 12 Jul 2017  ·  3Comments  ·  Source: ant-design/ant-design

What problem does this feature solve?

My team is using a linter that disallows the use of PropTypes.object. Because there are multiple instances where a shape can be formed, for these particular props (wrapperCol and labelCol) I would like to avoid writing the shape in each file or creating my own by copying/pasting with modification from the typescript file. I was hoping a readily made ColProps was available. After looking at the source code I see in ant-design/components/grid/col.tsx that there is a ColProps object that would be perfect to use, but is unavailable from the node_module version my team has. Is ColProps accessible anywhere in the current version?

What does the proposed API look like?

It would be nice to have ColProps available in some format like:
```
import React from 'react';
import PropTypes from 'prop-types';
import { Col } from 'antd';

const ColProps = Col.PropShape;
const propTypes = {
layout = PropTypes.shape({
labelCol: ColProps,
wrapperCol: ColProps,
}),
};

help wanted

All 3 comments

PR is welcomed @richardjboothe

ping~

You can try this:

import { Col } from 'antd';

PropTypes.shape(Col.propTypes);
Was this page helpful?
0 / 5 - 0 ratings