Cross Container Assignment
You can use the built-in pass task to pass data to another Container component.
Container Build-In Pass Task
The Container component will have 2 built-in pass tasks.
- $this
- $parent
The $this task
The $this task refers to the Container component attached to the current component, so in the event callback, you can use trigger.execTask('$this', {})
to pass the value to the current Container component.
<ES>{({$data}, context) => (
<button onClick={event => context.trigger.execTask('$this', {
username: ({$data}) => $data.username
})}>send username to demo2</button>
)}</ES>
The $parent task
The $parent task refers to the parent Container component of the Container component attached to the current component, so in the event callback, you can use trigger.execTask('$parent', {})
to pass the value to the parent Container Component.
<ES>{({$data}, context) => (
<button onClick={event => context.trigger.execTask('$parent', {
username: ({$data}) => $data.username
})}>send username to demo2</button>
)}</ES>