Through
Render Props based component to receive data in the though-container. It pass props received from the through-agent to a function. The Function as Child Compnent (FaCC) approach is used.
Props from selected agent or whole area if bearingKey (or direct) prop is not specified.
Props
area: String: The name of the area see GlossarybearingKey: String|undefined: define which agent data is selected, or whole area data if undefineddirect: String|bool|undefined: same asbearingKeybut alsobooleanis allowed andtrueis replaced withdefaultfor direct mappingdefault|defaultValue: any: default value passed to the render function if no such agent exists or in initial renderingchildren: function(props|area: Object): props from agent selected bybearingKeyordirector whole area if not specified
Examples
Let Agent is declared and two instanece of it are rendered some where in react tree like this:
const Agent = createAdvAgent('myarea', 'id')
...
<Agent id='first' text='hello'/>
<Agent id='second' text='world'/>
...Render data from each agent separtely
<Through area='myarea' direct='first' default={{text: 'loading...'}}>
{ ({id, text}) => <p>{text}</p> }
</Through>
<Through area='myarea' direct='second' default={{text: 'loading...'}}>
{ ({id, text}) => <p>{text}</p> }
</Through>Render data using whole area
<Through area='myarea'>
{(area) => {
<div>
{ ( area['first'] || {text: 'loading...'} ).text }
{ ( area['second'] || {text: 'loading...'} ).text }
</div>
}
</Through>Last updated