Fork me on GitHub
#om-next
<
2017-01-11
>
gordon01:01:44

@viebel What about (js/ReactDOM.render (your-component {:prop "foo"}) (google.dom/getElement "container-id"))?

mavbozo04:01:00

@viebel

(defui aComp
     Object
     (shouldComponentUpdate [this]
			    false))

Yehonathan Sharvit05:01:47

Thx @mavbozo will try it it soon

Yehonathan Sharvit06:01:47

In my case, it doesn’t work @mavbozo

Yehonathan Sharvit06:01:02

But I am realizing that my case is very special

Yehonathan Sharvit06:01:14

I’m adding a container to klipse

Yehonathan Sharvit06:01:49

When the code contains (require ‘cljsjs.react.dom), it breaks

Yehonathan Sharvit06:01:10

without it is is fine:

Yehonathan Sharvit06:01:24

Why does the fact that I’m loading react again (which is a really weird use case) is causing om.next to re-render the components even with shouldComponentUpdate => false?

mavbozo07:01:53

@viebel the result should be "Hello World!" rendered in right pane ?

Yehonathan Sharvit07:01:40

If you remove (require ‘cljsjs.react.dom), this is what you get

mavbozo07:01:15

when I load your first link, no "Hello World" rendered, but when I ctrl-enter in the code pane, the "Hello World" rendered

Yehonathan Sharvit07:01:32

this is exactly the problem

Yehonathan Sharvit07:01:55

when you re-evaluate the code with ctrl-enter, the bug doesnt reproduce,

Yehonathan Sharvit07:01:04

because react is not loaded again

mavbozo07:01:01

@viebel have you tried in Container component to render (dom/div #js {:id "klipse-container-wrapper"} nil) and fill its children in componentDidMount ?

Yehonathan Sharvit07:01:03

how would I fill its children?

mavbozo07:01:26

just use ordinary js function

Yehonathan Sharvit07:01:36

Is there a way to use om.dom - inside componentDidMount?

Yehonathan Sharvit07:01:33

and what will I do inside render()?

mavbozo07:01:08

basically, your Container component only knows about dom/div id:klipse-container-wrapper , the inside of the klipse-container-wrapper is outside react control

mavbozo07:01:22

maybe you could put another react root inside componentDidMount, never tried that before. I use that technique when I embed non-react dom library under react components tree

mavbozo07:01:20

the Container of the non-react dom library just render the div and in componentDidMount I set up the non-react dom.

mavbozo07:01:37

plus I set Container's shouldComponentUpdate to false

Yehonathan Sharvit07:01:35

It doesn’t work 😞

Yehonathan Sharvit07:01:49

Because componentDidMount is called again

mavbozo07:01:40

so, require-ing cljs.react.dom somehow re-mount react root

Yehonathan Sharvit07:01:08

I don’t know if it’s a om.next bug/feature or react

Yehonathan Sharvit07:01:16

Anyway, I need a way to prevent it

Yehonathan Sharvit13:01:30

@anmonteiro maybe you have an idea about ⬆️