如何使用 JSDocs 注释 ReactJS State-full "class" Component props
How to annotate ReactJS State-full "class" Component props using JSDocs
如何在全状态 "class" ReactJS 组件中注释道具以便在 render()
中获得自动完成功能?
但是我尝试了以下方法,它没有用:
export default class MyComponent extends Component {
/**
* @param {object} props
* @param {object} props.survey
* @param {string} props.survey.name
*/
constructor(props){
super(props)
// autocompletion works here
}
render() {
// autocompletion does not work here
return (
console.log(this.props.survey.name)
);
}
}
/**
* @typedef {object} props
* @property {object} survey
* @property {string} survey.name
* @extends {Component<props>}
*/
export default class MyComponent extends Component {
constructor(props){
super(props)
// autocompletion works here
}
render() {
// autocompletion should work here
const {survey} = this.props;
return (
console.log(survey.name)
);
}
}
如何在全状态 "class" ReactJS 组件中注释道具以便在 render()
中获得自动完成功能?
但是我尝试了以下方法,它没有用:
export default class MyComponent extends Component {
/**
* @param {object} props
* @param {object} props.survey
* @param {string} props.survey.name
*/
constructor(props){
super(props)
// autocompletion works here
}
render() {
// autocompletion does not work here
return (
console.log(this.props.survey.name)
);
}
}
/**
* @typedef {object} props
* @property {object} survey
* @property {string} survey.name
* @extends {Component<props>}
*/
export default class MyComponent extends Component {
constructor(props){
super(props)
// autocompletion works here
}
render() {
// autocompletion should work here
const {survey} = this.props;
return (
console.log(survey.name)
);
}
}