react-docgen
handler
for processing imported variables
Install
# install peer dependencies npm install react-docgen@2.21.0 recast@0.12.9 --save-dev# install this handler npm install react-docgen-imported-proptype-handler --save-dev
peerDependencies
note: it is necessary for this handler
and react-docgen
to share the same recast
dependency
npm ls recast
should show recast
as deduped
under react-docgen
<project name>@<project version>
├─┬ react-docgen@2.21.0
│ └── recast@0.12.9 deduped
└── recast@0.12.9
Usage example
const readFileSync writeFileSync = ;const resolve basename = ;const docgen = ;const glob = ;const importedProptypesHandler = default; const FILES = glob; const metadata = FILES; ;
Credit
Inspiration for this came from:
- Chandrasekhar Pasupuleti, initial implementation
- Siddharth Kshetrapal, for publishing react-docgen-external-proptypes-handler
- and the issue in
react-docgen
Why?
react-docgen
doesn't allow you to use variables from other files to use in propTypes
Example:
IconpropTypes = /** Icon name */ name: PropTypesisRequired
This doesn't work because it's parsed as a string and not an array
"props":
License
MIT © benjroy
Like it?
⭐️ this repo