如何使用 JSDoc 描述 React 状态?
换句话说,如何将其简化为一句台词?
/** The animal you're with */
let animal;
let setAnimal;
[animal, setAnimal] = useState()
换句话说...
/** what do you put here to describe `animal`? */
const [animal, setAnimal] = useState()
试试这个
/**
* @typedef Man
* @property {string} name
* @property {number} age
*/
/**
* @type {[Man, React.Dispatch<Man>]}
*/
const [data, setData] = useState({ name: "ben", age: 20 });