How to access the class name of a React object in this.props.children
Warning: this will not work in production if using minification
In ES6 every function has its name stored in property function.name
so you can get Class name with
import React from 'react'
...
getNameOfChildrenClass() {
const singleChild = React.children.only(this.props.children),
childClass = child.type
return childClass.name
}
I'm using React.children
utility