I have the following component:
import React from 'react'
import PropTypes from 'prop-types'
const MyComponent = ({ text1, text2 }) => {
return (
<div>
<p>{text1}</p>
<p>{text2}</p>
</div>
)
}
MyComponent.propTypes = {
text1: PropTypes.string,
text2: PropTypes.string,
}
MyComponent.defaultPropTypes = {
text1: 'React',
text2: 'is cool',
}
export default MyComponent
and then I am importing it like this
import MyComponent from "./MyComponent";
console.log(MyComponent.propTypes)
This prints a object with all propNames as a function. I am not able to get the type from the object. How do I get the proptype (in this example string) and "isRequired" from this component? I want to use it for automatically render a table with all possible propNames + PropType + isRequired + defaultPropType