Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map inside for results in rendered components that don't re-render #179

Closed
gacelita opened this issue Oct 24, 2017 · 1 comment
Closed

Comments

@gacelita
Copy link
Contributor

When calling om/build inside a map inside a for inside Sablono's html, components get rendered but won't get updated upon state changes:

(defn- inner [data owner]
  (reify
    om/IInitState
    (init-state [_]
      {:clicked false})
    om/IRenderState
    (render-state [_ state]
      (html
       [:div {:on-click #(om/set-state! owner :clicked true)}
        (str "Was it clicked? " (:clicked state))]))))

(defn- wrapper [data owner]
  (om/component
   (html
    [:div
     [:h4 "for mapv"]
     (for [i (range 2)]
       (mapv (fn [i] (om/build inner {:i i})) (range 2)))
     [:h4 "for map"]
     (for [i (range 2)]
       (map (fn [i] (om/build inner {:i i})) (range 2)))])))

If you render that, you'll see that clicking on the ones that use "for map" has no effect.
Changing map to mapv (as shown in the snippet) or putting any Sablono tag between "for" and "map" (for example :div) will also make it work.

Any help appreciated!

@gacelita
Copy link
Contributor Author

Updating sablono solved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant