Skip to content

Setting a :parent in the opts should not break reaction handling #41

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))))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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