-
Notifications
You must be signed in to change notification settings - Fork 57
How to move an Etch component's child? #69
Comments
Just at a glance, there are a couple small issues here. First, the However, I still think that won't result in the output you're looking for. You're mutating the Said another way: your components' |
@BinaryMuse Thanks, I see what you mean. Will it be a performance hit to recreate the button (and bind the event handler) every time a new row is appended? And if yes, then how can I manage that? Also, another thing that bothers me is the way of getting the actual |
If you use keys when creating your rows in the array, then the button shouldn't be recreated — Etch should be smart enough to insert the new rows above it. As for the button, you really shouldn't need to access it; what are you trying to do that requires using the ref? |
@BinaryMuse can you please elaborate? The README has no examples of using keys (which are badly needed btw). I'd love to see a code sample. And the thing is, the rows in my example do not contain just the button, they also have other children before the button (I omitted this fact to make the example clearer). And technically in my case the button is not even a button - it's a text field, I need a ref to access its content. So simply inserting a row above is not an option. Sorry if those facts should have been mentioned earlier, I just tried my best to abstract away the details :) |
Consider the following scenario:
I have a root component that holds some rows. I also have a button that should be a child of the latest row at all times.
On the root component creation it holds a single row which in turn holds the button, so the inital markup looks like this:
Then at some point I append another
Row
insideRoot
and I want the markup to look like this:Here's my attempt at doing this:
And when I call the
addRow
method after Root's establishment, I get the following markup:And it seems like the two buttons that appear in the markup are different DOM nodes.
How do I achieve my goal?
The text was updated successfully, but these errors were encountered: