@viebel What about (js/ReactDOM.render (your-component {:prop "foo"}) (google.dom/getElement "container-id"))
?
(defui aComp
Object
(shouldComponentUpdate [this]
false))
Thx @mavbozo will try it it soon
In my case, it doesn’t work @mavbozo
But I am realizing that my case is very special
I’m adding a container
to klipse
Here is a demo: https://goo.gl/NGAh4Z
When the code contains (require ‘cljsjs.react.dom)
, it breaks
without it is is fine:
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
?
@viebel the result should be "Hello World!" rendered in right pane ?
yes
If you remove (require ‘cljsjs.react.dom)
, this is what you get
when I load your first link, no "Hello World" rendered, but when I ctrl-enter in the code pane, the "Hello World" rendered
I know
this is exactly the problem
when you re-evaluate the code with ctrl-enter, the bug doesnt reproduce,
because react is not loaded again
@viebel have you tried in Container component to render (dom/div #js {:id "klipse-container-wrapper"} nil)
and fill its children in componentDidMount
?
Trying now...
how would I fill its children?
just use ordinary js function
Is there a way to use om.dom
- inside componentDidMount?
and what will I do inside render()
?
basically, your Container component only knows about dom/div id:klipse-container-wrapper , the inside of the klipse-container-wrapper is outside react control
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
the Container of the non-react dom library just render the div and in componentDidMount I set up the non-react dom.
plus I set Container's shouldComponentUpdate to false
It doesn’t work 😞
Because componentDidMount is called again
so, require-ing cljs.react.dom
somehow re-mount react root
Exactly
I don’t know if it’s a om.next
bug/feature or react
Anyway, I need a way to prevent it
@anmonteiro maybe you have an idea about ⬆️