dirtymikeandtheboys
dirtymikeandtheboys

Reputation: 541

Using reagent/reactify-component to create React class for use in JSX

I'm trying to adapt a Reagent (using re-frame) program that contains a component I want to be able to use from a plain React program. Essentially I to be able to take a Reagent (re-frame) component like this:

(defn my-component []
  (fn []
    (let [x (re-frame/subcribe [])]
      [:div (:something x)])))

Then, I want to have this render only when invoked from a js file, sort of like:

import myComponent from 'my-component'
class Example extends React.Component {
  render() {
    return (
      <myComponent
       x = "Hi"
       />
    );
  }
}

From all I can piece together it involves using reagent/reactify-component and/or reagent/create-class. But it's not very clear how these come together to make something a JS dev can use.

Upvotes: 5

Views: 964

Answers (1)

Victor Gil
Victor Gil

Reputation: 51

Check out reagent.core/as-element, it receives a hiccup vector and returns a react element.

Upvotes: 1

Related Questions