Reactjs 使用来自试剂的预定义反应组分?

Reactjs 使用来自试剂的预定义反应组分?,reactjs,clojurescript,om,reagent,Reactjs,Clojurescript,Om,Reagent,我有一些带有react组件抽象的外部UI,我想从试剂中重用它们,是否有任何方法可以直接通过从clojurescript传递数据来呈现预定义的react组件。我是clojurescript的初学者。让我们试试吧!我们可以从在js文件中编写组件开始 var CommentBox=React.createClass({displayName:'CommentBox', render:function(){ 返回( React.createElement('div',{className:“commen

我有一些带有react组件抽象的外部UI,我想从试剂中重用它们,是否有任何方法可以直接通过从clojurescript传递数据来呈现预定义的react组件。我是clojurescript的初学者。

让我们试试吧!我们可以从在js文件中编写组件开始

var CommentBox=React.createClass({displayName:'CommentBox',
render:function(){
返回(
React.createElement('div',{className:“commentBox”},
这是我的意见
)
);
}
});
然后我们可以直接从试剂中调用它:

(defonce应用程序状态
(atom{:文本“你好,世界!”
:plain{:comment“我可以从atom中获取道具”})
(定义注释框[]
js/评论框)
(defn hello world[]
[:div
[:h1(:text@app state)]
[注释框#js{:注释“我是一个普通的反应组件”}]
[注释框(clj->js(:plain@app state))]]
(试剂/渲染组件[hello world]
(.js/document(getElementById“app”))

注意,我们通过使用
#js
和将atom转换为纯js
clj->js
将道具作为纯js对象传递给
CommentBox
。如果我遗漏了一些内容,您可以在中找到其余部分。

为了补充这一点,本页底部还有一些信息: