elementType道具类型验证默认值

问题描述 投票:0回答:1

我想知道elementType道具验证的默认道具类型值是什么。如果没有通过任何组件,我只想不呈现任何内容。

PrivateRoute.defaultProps = {
  component: ???,
};

PrivateRoute.propTypes = {
  component: elementType,
};
reactjs react-proptypes
1个回答
0
投票

您可以简单地将null设为,因为react会忽略它。

© www.soinside.com 2019 - 2024. All rights reserved.