better-docs icon indicating copy to clipboard operation
better-docs copied to clipboard

How to document complex prop-types and display the correct data type?

Open mowagih96 opened this issue 4 years ago • 2 comments

When I try to document the following prop:

/**
   * Form fields inputs
   */
  inputs: PropTypes.arrayOf(
    PropTypes.shape({
      id: PropTypes.string,
      name: PropTypes.string,
      placeholder: PropTypes.string,
      type: PropTypes.string,
      data: PropTypes.arrayOf(
        PropTypes.shape({
          value: PropTypes.string,
          label: PropTypes.string
        })
      )
    })
  ).isRequired

The generated document displays this: image

I believe this is not correct, The result should be Array, Array.<Object>, etc.. How to tweak this or customize the scripts? Because I can't find it anywhere.

mowagih96 avatar Nov 22 '20 11:11 mowagih96

Even if you just have a single shape, the result is insufficient. For example,

StudienDetails.propTypes = {
  studie: PropTypes.shape({
    studienleitername: PropTypes.string,
    studienleiteremail: PropTypes.string,
    studienstunden: PropTypes.number,
    startdatum: PropTypes.instanceOf(Date),
    enddatum: PropTypes.instanceOf(Date),
    kriterien: PropTypes.string,
    details: PropTypes.string,
  }),
}

displays

Name Type Required Description Default
studie shape No

cayhorstmann avatar Apr 21 '22 17:04 cayhorstmann

I have the same problem

Gi-wq avatar Apr 28 '22 06:04 Gi-wq