How to detect a React component vs. a React element?

前端 未结 7 1970
广开言路
广开言路 2020-12-02 10:04

React.isValidElement tests true for both React components as well as React elements. How would I test, specifically, that an object is a React component? Curren

7条回答
  •  旧时难觅i
    2020-12-02 10:26

    ReactComponent.prototype.isReactComponent = {};
    

    33 of /node_modules/react/lib/ReactComponent.js

    Install using npm. At this point, there is no direct method available to check for its validity. What you are doing is correct.

提交回复
热议问题