-
Notifications
You must be signed in to change notification settings - Fork 50
API to remove me from parent #21
Comments
Here is how I do it var counts = cursor.refine('very', 'deeply', 'nested', 'counts'); I think in general to remove something from the collection you'll want to work with a cursor to the collection as a whole - because you want access to the entire collection API to remove/add/filter etc |
Ok, how about if I wanted to add a delete button to the EDIT: I guess I could do it by giving all components their key and a cursor pointing to their parent. Still not as clean as a |
This is how I would do it. I have not thought a Note that if we finish #10, we would have access to |
Seems weird that React.addons.update doesn't have a More thinking out loud: A cursor could have a pointer to its parent (so we must hack A Hmm - maybe having all refined cursors carry a pointer to their parents is a can of worms? |
EDIT: That won't work, as we won't get to eventual references that way. But if all cursors have access to their parents anyway, we can do a quick recursive check through parents to see if an ancestor has been deleted. |
And we must also decide what value a removed cursor should return. Or maybe trying to display a removed cursor is always an error? Ideally it should never happen, if the cursor is state in the top-level component. |
Adding support to navigate back up the path wouldn't be a hack, real functional zippers support that. E.g. https://github.com/xsc/rewrite-clj The argument against allowing |
I think that argument is a strong one. Spontaneously I say that although we internally keep a pointer to the parent in order to implement |
Seems React are deprecating |
Interesting, I don't know what to do about that, I guess we can keep an eye |
Declined |
During my plays with react-cursor I've often wished I could
delete
a cursor, removing it from its parent (if it has one). Or am I misunderstanding something in barking up this tree? Say for example we wanted to add a delete button to theClicker
components in the helloworld webapp example. Is there a better way to do that without my imaginarydelete
API?The text was updated successfully, but these errors were encountered: