This should make things clear: http://facebook.github.io/react/docs/reconciliation.html
On Saturday, 18 October 2014, Daniel Kersten <[email protected]> wrote: > Can you provide a little more code? Specifically, the render function of > the events parent. I assume you are doing something like (om/build-all > event-component (:events factory)) > > Is there a unique id in each event by any chance? Presumably what is > happening is that react doesn't properly detect which event was actually > removed - only that one of them was removed (I've seen this a few times...) > so if you provide what React calls a "key" then it can use this to > disambiguate and correctly render the list. For example: > > If your events look like this {:id 3 :other :data} > > Then you can do something like this: > > (om/build-all event-component all-events {*:key :id*}) > > If you don't have a field in the event that can be used as a key (a > number, string or keyword that is unique across all events), then you could > try something like this instead: > > (map-indexed > (fn [idx event] > (build event-component event {*:react-key idx*})) > all-events) > > https://github.com/swannodette/om/wiki/Documentation#build > > On 18 October 2014 14:33, Andreas Liljeqvist <[email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote: > >> I have a vector of events in my factory-row. >> >> An event can be selected by clicking on it: >> >> (merge {:onClick #(om/set-state! owner :selected true)} >> (when selected {:style {:background >> "white"}})) >> >> If it is selected it will display a white background. >> This works fine. >> >> Problem is when I delete an item. >> 1. Select the first item on the row (turns white) >> 2. Delete the first item on the row (item disappears but the second item >> turns white) >> >> (will-mount [_] >> (let [delete (om/get-state owner :delete)] >> (go (loop [] >> (let [event (<! delete)] >> (om/transact! factory :events >> (fn [xs] (vec (remove (partial = event) >> xs)))) >> (recur)))))) >> >> >> Why is local-state propagated to the next item in the list? >> >> Thanks >> >> -- >> Note that posts from new members are moderated - please be patient with >> your first post. >> --- >> You received this message because you are subscribed to the Google Groups >> "ClojureScript" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] >> <javascript:_e(%7B%7D,'cvml','clojurescript%[email protected]');> >> . >> To post to this group, send email to [email protected] >> <javascript:_e(%7B%7D,'cvml','[email protected]');>. >> Visit this group at http://groups.google.com/group/clojurescript. >> > > -- > Note that posts from new members are moderated - please be patient with > your first post. > --- > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <javascript:_e(%7B%7D,'cvml','clojurescript%[email protected]');> > . > To post to this group, send email to [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>. > Visit this group at http://groups.google.com/group/clojurescript. > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
