error handling - How to get parent component's name in React? -


i provide nice error messages of components, react does, example:

warning: each child in array should have unique “key” prop. check render method of mycomponent. see fb.me/react-warning-keys more information.

this message provides info context of error. know can find in debugger, want make debugging easier me , fellow programmers.

while it's not clear how you'd use promise component mentioned in comment, try this:

var componentname = this.constructor.displayname || constructor.name || undefined; 

it's inspired this function in reactjs code looks @ constructor build name during react element validation.

but, if want parent's name, isn't possible through documented means , fragile if built code depending on specific internal implementation. it's 1 way flow of information child doesn't need link parent way of normal architecture.

if need parent name, you'd need value , pass through children i'm sure isn't desireable.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -