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

letdom and dom-node does not work (as described) #37

Open
dfrese opened this issue May 28, 2019 · 0 comments
Open

letdom and dom-node does not work (as described) #37

dfrese opened this issue May 28, 2019 · 0 comments

Comments

@dfrese
Copy link
Member

dfrese commented May 28, 2019

The documentation of letdom is quite outdated, but in particular states that one could access 'bound' dom element in its 'own' event handler:

      (reacl.core/defclass search-bar
        app-state [filter-text in-stock-only on-user-input]
        render
        (fn [& {:keys [dom-node]}]
          (dom/letdom
           [textbox (dom/input
                     {:type \"text\"
                      :placeholder \"Search...\"
                      :value filter-text
                      :onChange (fn [e]
                                  (on-user-input
                                   (.-value (dom-node textbox))
                                   (.-checked (dom-node checkbox))))})
            checkbox (dom/input
                      {:type \"checkbox\"
                       :value in-stock-only
                       :onChange (fn [e]
                                   (on-user-input
                                    (.-value (dom-node textbox))
                                    (.-checked (dom-node checkbox))))})]
           (dom/form
            textbox
            (dom/p
             checkbox
             \"Only show products in stock\")))))
  1. render as a function of {:dom-node ..} is not possible anymore, I'm quite sure.
  2. a global dom-node function exists, but that takes the component as a first arg.
  3. Calling dom-node in an event handler like here returns undefined (at least in a simplified test-case)
    What does still work is rendering the things bound by letdom.

Given that refs have been introduced a while ago, I'd say we can quickly phase out letdom all together. Also, people collect the states of the two components in a common local or app-state anyway, and never access anything else than the .-target of an event handler.

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