Fork me on GitHub
#om
<
2017-12-30
>
Ho0man06:12:02

Hi, what is the difference between creating a plain js dom element like (.createElement js/document "DIV") and creating one using om wrappers om.dom/div?

alasdair12:12:44

The om.dom functions wrap React.createElement so (I believe) the latter creates a React element, the former goes straight to the browser DOM.

alasdair12:12:57

The om.dom functions wrap React.createElement so (I believe) it creates a React element, the js call goes straight to the browser DOM.

rarous20:12:07

Correct. First one creates DOM element, the second VirtualDOM element.

Ho0man09:12:26

Great, thanks.

Ho0man09:12:09

I had a follow-up question though : I'm using a lib that gets a browser dom element and operates on that (draws a chart), how can I use that with om-next?

jthomson09:01:51

One way of doing this kind of thing is adding a :ref to the dom element, which is a fn that is given the dom element stores a reference to it on the component. (e.g. (fn [el] (set! (.-chartWrapper this) el))) Then you can access it directly in lifecycle methods to set up / tear down your non-react component.

alasdair12:12:57

The om.dom functions wrap React.createElement so (I believe) it creates a React element, the js call goes straight to the browser DOM.

Ho0man09:12:09

I had a follow-up question though : I'm using a lib that gets a browser dom element and operates on that (draws a chart), how can I use that with om-next?