4

I'm trying to use react-router in my Clojurescript Reagent project. The problem is, react-router requires that components pass React.isValidClass(component), which in React 0.11.2 is defined as:

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

Reagent seems to generate components as an object instead of a function. Here is my code:

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

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

Has anyone worked out how to make this sort of interop work?

erikcw
  • 10,787
  • 15
  • 58
  • 75
  • i found an attempt to do the same on github: https://github.com/ghedamat/reagent-react-router, may be it helps. – zarkone Jul 29 '15 at 05:32

1 Answers1

1

What reagent-react-router does to make this work is use reagent.core/reactify-component. The reactify-component exists to make Reagent components valid React components for these kinds of inter-op scenarios.

Pyrce
  • 8,296
  • 3
  • 31
  • 46
nilern
  • 156
  • 2