使用ClojureScript中的ReactBootstrap组件

时间:2016-01-17 13:53:14

标签: javascript twitter-bootstrap-3 clojurescript

我有这种lein依赖:

[cljsjs/react-bootstrap "0.27.3-0"]

,在cljs代码中我试图引用一个像这样的React Bootstrap组件:

(defn button [info]
  (js/ReactBootstrap.Nav (js->clj {:key (:id info)}) (:name info))) 

我遇到的问题不在于代码,而是因为组件(ReactBootstrap.Nav)未被识别。我在浏览器控制台中收到此错误消息:

Uncaught ReferenceError: ReactBootstrap is not defined

除了lein依赖项之外,我还需要执行哪些步骤才能使用ClojureScript识别React Bootstrap组件?

编辑这是一个愚蠢的错误(上面的错误消息是由于缺少或不正确的要求)。我收到了很多错误消息。例如:

Uncaught Error: Invariant Violation: om_alarming$components$nav$MenuBar.render(): A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object.

我正在尝试使用Om Next中的这些Bootstrap组件。我没有找到任何Om Next示例应用程序的例子,它们使用第三方组件库的方式来查看它们如何组合在一起......

(Om Next在写这篇文章的时候是alpha版)

1 个答案:

答案 0 :(得分:1)

你还必须require。来自README

(ns application.core ;; replace with your namespace of course
  (:require cljsjs.react-bootstrap))

注意:我还检查了包中是否存在此函数,this is the case