childContextTypeHandler
Finds legacy React childContextTypes declarations and adds them to the
documentation under the childContext field.
It uses the same PropTypes parsing logic as
propTypeHandler, but writes descriptors to
childContext instead of props.
Examples
When the childContextTypeHandler is active either of these components will
result in the output below.
component.tsx
import PropTypes from 'prop-types';
class MyComponent extends React.Component {
static childContextTypes = {
theme: PropTypes.string,
disabled: PropTypes.bool.isRequired,
};
render() {
return <div />;
}
}component.tsx
import PropTypes from 'prop-types';
function MyComponent() {
return <div />;
}
MyComponent.childContextTypes = {
theme: PropTypes.string,
disabled: PropTypes.bool.isRequired,
};Output
JSON
[
{
"childContext": {
"theme": {
"type": {
"name": "string"
},
"required": false
},
"disabled": {
"type": {
"name": "bool"
},
"required": true
}
}
}
]Source
Last updated on