0

React get components name

Hello everyone! given a react component, is it possible to get the name of the class that component is instance of? something like this: class Foo extends React.Component { ... } const bar = (<Foo/>); /* bar instanceof Foo //true bar.type //Foo*/ I've tried bar.type but it gave me the function which generated it, instead of the string "Foo" i was looking for *instanceof is just an example, but it obviously doesn't work* are there any other way to get back the generating class (or function) name? Thanks in advance!

10th Oct 2018, 3:05 PM
Daniele
Daniele - avatar
2 Réponses
8th Nov 2018, 7:15 AM
Biel Blue
Biel Blue - avatar
0
Thanks Biel Blue !
8th Nov 2018, 7:06 PM
Daniele
Daniele - avatar