Om based application inside React based application

I have a video component written in ClojureScript (based on Om) and a page written in JavaScript (based on React) and I want to use that video component in that page. They do not interact with each other, video component is completely autonomous. I came up with the following code, which works, but I'm not sure if it's OK to have ClojureScript app inside React app:

class Page extends React.Component {
  render: () => {
    return <div><div id="video"></div><Comments/></div>;
  }
}

React.render(<Page/>, document.getElementById('page'), function() {
  // video is an instance of ClojureScript application
  video.client.render({id: 'abc'});// calls React.render(<VideoPlayer/>, document.getElementById('video'));
});

It results in the following DOM:

<div id="page">
  <div>
    <div id="video">
      <CljsVideoPlayer/>
    </div>
    <Comments/>
  </div>
</div>

Is it OK to include a ClojureScript component into a React based page like this?

Answers


Since you are never calling om/root, your component shouldn't use any of the unique features that om provides: instrumentation, listening to transactions, etc.

In that case, you've effectively written a React component in cljs + om, and things should work without problems.

If you want to make sure, post a gist with the component and we'll check if it assumes any om provided functionality, that is not provided by React.


Need Your Help

MVC - Ajax form - return partial view doesnt update in <div> target

asp.net-mvc asp.net-ajax asp.net-mvc-partialview

I have an index view that I want to update automatically as the user types in a client id. I got something similiar to work (only it was updating just a label) - but this will not work.

Unexpected $markerCount (T_VARIABLE)

php

Not sure what I'm missing here.... The error I get is...