How to get the propTypes? of package components by react High-level components

problem description

currently, you need to do a HOC component debugging tool. If you select a component wrapped by HOC, there will be a selected box and a floating layer to prompt the component data. If there is a propTypes, make some warnings and prompts. During the development of
, it is found that all propTypes fetches are func.

related codes

const HOC = (Ele) => class extends Component{
    render() {
        console.log(Ele.propTypes)
        return <Ele {...this.props} />
    }
}

what result do you expect? What is the error message actually seen?

clipboard.png

Aug.31,2021

in fact, it is already a function

.

suppose you use the propTypes module.
Let's take propTypes.string as an example. We can look at the source code:

export default {

  string: createPrimitiveTypeChecker('string') // function

};

https://github.com/aackerman/.

The

function really works when the component accepts the prop and passes the prop accepted by the component to the function as an argument.

https://github.com/facebook/r.

Menu