加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

reactjs – Reagent生成一个传递React.isValidClass(组件)的Reac

发布时间:2020-12-15 09:30:34 所属栏目:百科 来源:网络整理
导读:我正在尝试在我的Clojurescript Reagent项目中使用react-router.问题是,react-router要求组件传递React.isValidClass(组件),在React 0.11.2中定义为: ReactDescriptor.isValidFactory = function(factory) { return typeof factory === 'function' factory.
我正在尝试在我的Clojurescript Reagent项目中使用react-router.问题是,react-router要求组件传递React.isValidClass(组件),在React 0.11.2中定义为:

ReactDescriptor.isValidFactory = function(factory) {
  return typeof factory === 'function' &&
         factory.prototype instanceof ReactDescriptor;
};

试剂似乎生成组件作为对象而不是函数.这是我的代码:

(defn home []
  [:div [:h1 "Home Page placeholder"]])

(reagent/as-component (home)) ; => #<[object Object]>

有没有人研究过如何进行这种互操作?

解决方法

reagent-react-router使这项工作的作用是使用reagent.core / reactify-component. reptify组件的存在使Reagent组件有效React组件用于这些类型的操作间方案.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读