8000 Setting a :parent in the opts should not break reaction handling · Issue #41 · active-group/reacl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Setting a :parent in the opts should not break reaction handling #41
Open
@dfrese

Description

@dfrese

Currently, a 'reaction' with an explicit target component, can stop working when :parent is set in the opts. But the :parent should only affect reactions that use :parent as the target:

In this test, the app-state change is silently lost:

(deftest parent-reaction-test
  (let [c1 (reacl/class "child" this state []
                        render (dom/div)
                        handle-message
                        (fn [msg]
                          (reacl/return :app-state msg)))
        received (atom nil)
        p1 (reacl/class "parent" this state [gparent]
                        render (c1 (reacl/opt :parent gparent
                                              :reaction (reacl/reaction this identity))
                                   state)
                        handle-message
                        (fn [msg]
                          (reset! received msg)
                          (reacl/return :app-state msg)))
        g1 (reacl/class "grandparent" this []
                        local-state [state nil]
                        render (p1 state this))

        c (tu/mount g1)]
    (tu/send-message! (xpath/select c (xpath/>> ** c1))
                      :test)
    (is (= @received :test))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0