2015-10-03 01:57:40 +08:00
---
layout: docs
title: InjectedComponent
2015-10-04 04:56:58 +08:00
edit_url: "https://github.com/nylas/N1/blob/master/src/components/injected-component.cjsx"
2015-10-03 01:57:40 +08:00
---
2015-10-02 03:34:16 +08:00
2015-10-03 01:57:40 +08:00
< h2 > Summary< / h2 >
2015-10-02 03:34:16 +08:00
2015-10-03 01:57:40 +08:00
< div class = "markdown-from-sourecode" >
< p > < p > InjectedComponent makes it easy to include dynamically registered
2015-10-02 03:34:16 +08:00
components inside of your React render method. Rather than explicitly render
a component, such as a < code > < Composer> < / code > , you can use InjectedComponent:< / p >
< pre > < code class = "lang-coffee" > < span class = "hljs-tag" > < < span class = "hljs-title" > InjectedComponent< / span > < span class = "hljs-attribute" > matching< / span > =< span class = "hljs-value" > {role:"Composer"}< / span > < span class = "hljs-attribute" > exposedProps< / span > =< span class = "hljs-value" > {draftClientId:123}< / span > /> < / span >
< / code > < / pre >
< p > InjectedComponent will look up the component registered with that role in the
2015-10-03 01:57:40 +08:00
< a href = 'componentregistry.html' > ComponentRegistry< / a > and render it, passing the exposedProps (< code > draftClientId={123}< / code > ) along.< / p >
2015-10-02 03:34:16 +08:00
< p > InjectedComponent monitors the ComponentRegistry for changes. If a new component
is registered that matches the descriptor you provide, InjectedComponent will refresh.< / p >
< p > If no matching component is found, the InjectedComponent renders an empty div.< / p >
< / p >
< / div >
2015-10-03 01:57:40 +08:00
< ul >
< / ul >
< h3 > Class Properties< / h3 >
< h4 id = propTypes > propTypes < a href = "#propTypes" class = "link" > < / a > < / h4 >
< p > < p > React < code > props< / code > supported by InjectedComponent:< / p >
< / p >
< table class = "arguments" >
< tr >
< td style = "width:15%;" >
< em > matching< / em >
< / td >
< td >
2015-10-04 04:56:58 +08:00
2015-10-03 01:57:40 +08:00
< p > Pass an < a href = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/object' > Object< / a > with ComponentRegistry descriptors. This set of descriptors is provided to < a href = 'ComponentRegistry.html#findComponentsForDescriptor' > ComponentRegistry::findComponentsForDescriptor< / a > to retrieve the component that will be displayed.< / p >
2015-10-04 04:56:58 +08:00
2015-10-03 01:57:40 +08:00
< / td >
< / tr >
< tr >
< td style = "width:15%;" >
< em > className< / em >
< / td >
< td >
< span class = "optional" > Optional< / span >
< p > A < a href = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string' > String< / a > class name for the containing element.< / p >
2015-10-04 04:56:58 +08:00
2015-10-03 01:57:40 +08:00
< / td >
< / tr >
< tr >
< td style = "width:15%;" >
< em > exposedProps< / em >
< / td >
< td >
< span class = "optional" > Optional< / span >
< p > An < a href = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/object' > Object< / a > with props that will be passed to each item rendered into the set.< / p >
2015-10-04 04:56:58 +08:00
2015-10-03 01:57:40 +08:00
< / td >
< / tr >
< / table >