mirror of
https://github.com/strapi/strapi.git
synced 2025-11-17 18:51:22 +00:00
SelectTree: Improve PropTypes for options
This commit is contained in:
parent
18e495f6e0
commit
9b162d8e99
@ -88,13 +88,25 @@ const SelectTree = ({ options: defaultOptions, maxDisplayDepth, ...props }) => {
|
|||||||
return <Select components={{ Option: CustomOption }} options={options} {...props} />;
|
return <Select components={{ Option: CustomOption }} options={options} {...props} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const OptionShape = PropTypes.shape({
|
||||||
|
value: PropTypes.number.isRequired,
|
||||||
|
label: PropTypes.string.isRequired,
|
||||||
|
children: PropTypes.array,
|
||||||
|
});
|
||||||
|
|
||||||
|
OptionShape.children = PropTypes.arrayOf(PropTypes.shape(OptionShape));
|
||||||
|
|
||||||
|
OptionShape.defaultProps = {
|
||||||
|
children: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
SelectTree.defaultProps = {
|
SelectTree.defaultProps = {
|
||||||
maxDisplayDepth: 5,
|
maxDisplayDepth: 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
SelectTree.propTypes = {
|
SelectTree.propTypes = {
|
||||||
maxDisplayDepth: PropTypes.number,
|
maxDisplayDepth: PropTypes.number,
|
||||||
options: PropTypes.array.isRequired,
|
options: PropTypes.arrayOf(OptionShape).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SelectTree;
|
export default SelectTree;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user