From 89cd39d7c01da84c36d887e13153da867fc1a5a9 Mon Sep 17 00:00:00 2001 From: Stefan Dombrowski Date: Wed, 15 Oct 2014 10:46:43 +0200 Subject: [PATCH] Show how the displayName can be accessed --- docs/docs/ref-03-component-specs.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/docs/ref-03-component-specs.md b/docs/docs/ref-03-component-specs.md index 20efc831cc3..3183b6cf125 100644 --- a/docs/docs/ref-03-component-specs.md +++ b/docs/docs/ref-03-component-specs.md @@ -96,6 +96,16 @@ string displayName ``` The `displayName` string is used in debugging messages. JSX sets this value automatically; see [JSX in Depth](/react/docs/jsx-in-depth.html#react-composite-components). +For reading it can be accessed with `constructor.displayName`. For example: + +```javascript +var MyComponent = React.createClass({ + displayName: 'MyDisplayName', + render: function() { + return
{this.constructor.displayName}
; + } +}); +``` ## Lifecycle Methods