首页 > 解决方案 > 重新框架:未注册事件处理程序

问题描述

我的重新框架 views.cljs 有:

(re-frame/dispatch [::re-graph/init
                    {:http-url "https://api.spacex.land/graphql"
                     :ws-url nil
                      :http-parameters {:with-credentials? false}}])

(re-frame/dispatch [::re-graph/query
                    "{ launches { id, mission_name } }"  ;; your graphql query
                    [::update-data]])

我的 events.cljs 有:

(re-frame/reg-event-db
 ::update-data
 (fn [db [_ {:keys [data errors] :as payload}]]
   (-> db
     (assoc :errors errors)
     (assoc :data data))))

但我不断收到此错误:

core.cljs:3919 re-frame: no :event handler registered for: undefined

标签: clojurescriptre-frame

解决方案


解决方案是包含nil查询变量

(re-frame/dispatch
 [::re-graph/query
  "{launches {id, mission_name}}"
  nil
  [:add-launches]])

推荐阅读