Kind 2 String - a parser for extract-react-typesKind 2 String is designed to take the data structures output by extract-react-types and convert them to a (useful) string, as well as performing safe traversal through the output of
extract-react-typesso that trying to display information in your docs does not throw errors.
It exposes a
convertmethod which allows you to ensure the data structure resolves to a string. It also exposes its
converterobject, allowing you to overwrite converters of your choice, if you wish to perform some other action other than the default string converter.
import generatedData from './extract-react-type-write-location'; import convert from 'kind2string'; export default () => <div>convert(generatedData)</div>;
Also, if you are handling the kinds in a custom way, it is good to pass the final kind to
kind2string, to ensure that you always pass a string to your react components.
For examples of how to use this, the @atlaskit/docs uses this package. A good pattern on how to implement
kind2stringcan be found in the prettyproptypes file.