I think the JSDoc ment for a react ponent could look like this:
/**
* My ponent...
*
* @namespace MyComponent
* @memberof appponents
*/
appponents.MyComponent = React.createClass({
})
But how should it look like if I'm using ES6?
/**
* My ponent...
*
* @namespace MyComponent
* @memberof ??
*/
class MyComponent extends Component {
/**
* PropTypes
* @param {string} element
*/
static propTypes = {
element: PropTypes.object
}
/**
* Constructor
* How to take care about onChange and states?
*/
constructor () {
super()
this.onChange = this.onChange.bind(this)
this.state = {
anything: true
}
}
}
Also I do not understand how to document the static propTypes and the constructor...
Are there more tags missing for the 'best' documentation possible?
I think the JSDoc ment for a react ponent could look like this:
/**
* My ponent...
*
* @namespace MyComponent
* @memberof app.ponents
*/
app.ponents.MyComponent = React.createClass({
})
But how should it look like if I'm using ES6?
/**
* My ponent...
*
* @namespace MyComponent
* @memberof ??
*/
class MyComponent extends Component {
/**
* PropTypes
* @param {string} element
*/
static propTypes = {
element: PropTypes.object
}
/**
* Constructor
* How to take care about onChange and states?
*/
constructor () {
super()
this.onChange = this.onChange.bind(this)
this.state = {
anything: true
}
}
}
Also I do not understand how to document the static propTypes and the constructor...
Are there more tags missing for the 'best' documentation possible?
Share Improve this question edited Jul 13, 2017 at 6:33 user3142695 asked Jul 13, 2017 at 6:22 user3142695user3142695 17.4k55 gold badges194 silver badges374 bronze badges2 Answers
Reset to default 9Since you are using ES6 modules, you don't need to specify the namespace nor the '@memberof'.
There is a jsdoc-react but i would remend to use an interactive ponent style guide like styleguidist which handle both jsdoc and proptypes. According to their documentation, they don't ment constructor.
Here is a list of multiples react living style guide
You can use JSDoc with better-docs theme/plugin
- It auto-generate documentation(Readme and HTML Pages)
- Highly Customizable
- Live Preview of Your Components
Check it out here: https://www.inkoop.io/blog/a-guide-to-js-docs-for-react-js/