0

Is there a good way to tell if a child is a user-defined ReactJS component or an "html" component (React.DOM.div, React.DOM.p, etc.)?

1
  • 2
    Why would you need to check for this? Commented Nov 6, 2014 at 21:36

1 Answer 1

1

In React 0.12 you check if the "type" property is a string. In older versions you would have to inspect the "constructor" property (child.constructor.name would be a good hint)

var Element = <p>Some Tag</p>;
if (_.isString(Element.type)) console.log("got DOM primitive")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.