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!
2 odpowiedzi
+ 8
Thi can help you:
https://stackoverflow.com/questions/43800784/get-component-name-in-react
0
Thanks Biel Blue !