Skip to content

No queries exist for component path #895

Open
@roti

Description

@roti

The code below throws "No queries exist for component path (om-tutorial.core/RootView om-tutorial.core/Counter)" when clicking on the button.

To me it's quite strange that this is happening, since this is a very simple case, so maybe I'm doing something wrong, but if that's the case I couldn't figure out what.

Error occurs here.

(ns om-tutorial.core
  (:require [goog.dom :as gdom]
            [om.next :as om :refer-macros [defui]]
            [om.dom :as dom]))

(def app-state (atom {:page :counter
                      :count 0  }))

(defn read [{:keys [state] :as env} key params]
  (let [st @state]
    (if-let [[_ value] (find st key)]
      {:value value}
      {:value :not-found})))

(defn mutate [{:keys [state] :as env} key params]
  (if (= 'increment key)
    {:value {:keys [:count]}
     :action #(swap! state update-in [:count] inc)}
    {:value :not-found}))



(defui Counter
  static om/IQuery
  (query [this]
    [:count])
  Object
  (render [this]
    (let [{:keys [count]} (om/props this)]
      (dom/div nil
               (dom/span nil (str "Count: " count))
               (dom/button
                 #js {:onClick #(om/transact! this '[(increment)])}
                 "Click me!")))))

(def counter (om/factory Counter))

(defui RootView
  static om/IQuery
  (query [this]
    [:count :page])
  Object
  (render [this]
    (let [props (om/props this)]
      (dom/div nil
               (counter (om/props this))))))

(def reconciler
  (om/reconciler
    {:state app-state
     :parser (om/parser {:read read :mutate mutate})}))

(om/add-root! reconciler
              RootView (gdom/getElement "app"))

:class-path->query apparently does not contain the expected path:

dev:om-tutorial.core=> @(om/get-indexer reconciler) 
{:class->components
 {om-tutorial.core/RootView #{#object[om-tutorial.core.RootView]},
  om-tutorial.core/Counter #{#object[om-tutorial.core.Counter]}},
 :data-path->components
 {[]
  #{#object[om-tutorial.core.RootView]
    #object[om-tutorial.core.Counter]}},
 :ref->components {},
 :prop->classes
 {:count #{om-tutorial.core/RootView},
  :page #{om-tutorial.core/RootView}},
 :class-path->query
 {[om-tutorial.core/RootView] #{[[:count :page] nil]}}}

I tested on beta1 and the latest snapshot.

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