ReactBootstrap.Modal未在Reagent应用程序中显示

时间:2016-04-27 20:51:35

标签: clojurescript reagent

我正在尝试在Reagent应用程序中使用ReactBootstrap的模态组件,但得到一个"无法读取属性' findDOMNode'未定义"尝试显示模态时出错。

我有[cljsjs / react-bootstrap" 0.28.1-1"]作为我项目中的依赖项。

以下是我用来测试的来源:

(ns react-bootstrap-test.core
  (:require
    [reagent.core :as r]
    cljsjs.react-bootstrap))

(def rbutton (r/adapt-react-class js/ReactBootstrap.Button))
(def rmodal (r/adapt-react-class js/ReactBootstrap.Modal))
(def modal-header (r/adapt-react-class js/ReactBootstrap.Modal.Header))
(def modal-title (r/adapt-react-class js/ReactBootstrap.Modal.Title))
(def modal-body (r/adapt-react-class js/ReactBootstrap.Modal.Body))

(defonce show-modal (r/atom false))

(defn modal-test []
  [:div
   [rbutton {:bsStyle "primary"
             :bsSize "large"
             :active true
             :on-click (fn [e]
                         (reset! show-modal true)
                         (.stopPropagation e))}
    "Show Modal"]

   [:div.rmodal
    [rmodal {:show @show-modal}
     [modal-header
      [modal-title "Title"]]
     [modal-body
      [:h3 "Body"]]]]])

(r/render-component [modal-test]
                    (. js/document (getElementById "app")))

0 个答案:

没有答案