3 ms·
Like this <my-tag> <nested-tag1 if={ parent.val }/> <nested-tag2 if={ !parent.val }/> <input oninput={ edit }> edit(e) { this.val = e.target.val
by tipiirai 12y ago
Like this
<my-tag>
<nested-tag1 if={ parent.val }/>
<nested-tag2 if={ !parent.val }/>
<input oninput={ edit }>
edit(e) {
this.val = e.target.value
}
</my-tag>
- jasim 12y agoThanks for responding. You might want to look at insin's comment above. In insin's code example, the conditional doesn't work on a component, but does on a normal HTML tag. Would that be a bug? The lack of true conditionals is a turn-off for me. React's conditionals lets you build things like react-router without any extra semantics, in which the router picks up the appropriate component based on the URL.
- tipiirai 12y agoOn the child component you refer the parent data with `parent.` prefix.
- insin 12y agoToggling display of child components with an "if" attribute doesn't work if I change the expression to parent.component either - evaluating a component attribute declared in a parent in the context of the child is pretty surprising, if that's what happens. It seems like using a value attribute on a <select> doesn't set the selected value, I had to manually set selected on the <option>s to get it to work, and updating the value from elsewhere doesn't seem to affect the selected option either way. Checkbox events are throwing "SyntaxError: function statement requires a name". Wrapping the display of the disabled value in () instead of [] throws "SyntaxError: missing formal parameter" on load. Updated gist showing these here: http://bl.ocks.org/insin/5e0bf04cf1f701c235ad http://bl.ocks.org/insin/5e0bf04cf1f701c235ad I don't see any docs on using forms - is support for form elements still a work in progress?