4
votes

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?

1
i found an attempt to do the same on github: github.com/ghedamat/reagent-react-router, may be it helps. - zarkone

1 Answers

1
votes

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.