Hi Lucas, thanks for the info.
You are right - I should have been clearer. My scenario is that the component
hierarchy itself isn't changing only the app-state that the hierarchy is mapped
to.
In its simplest form, think of a combo-box. The app-state is {:text "" :results
[]}. The component has an input field mapped to :text and a <ol> mapped to
:results. Changing :text populates :results accordingly.
Your point about keys is worth investigating. Where I am setting keys (mainly
on dynamic children) they aren't changing. I'm not setting them elsewhere
though, which might be worth a look.
Another clarity question - if an ancestor component is remounted does that
cause all children to be remounted? It might be something much higher up in the
hierarchy causing a remount...
Thanks for confirming my assumptions anyway, I will dig in a bit deeper.
On Thursday, 4 December 2014 11:39:44 UTC, Lucas Bradstreet wrote:
> Hi,
>
> Changes to app state *can* cause components to be unmounted. Imagine a
> component that renders another component, if a boolean value in the app state
> is true, otherwise it renders and empty div. When the boolean changes from
> true to false and the component is re-rendered, the subcomponent will be
> unmounted.
>
> However, if the subcomponent should be re-rendered in both cases, it should
> not be unmounted.
>
> Thinking about it, you're probably mistakenly using a different react-key
> between the renders. This will cause a new component to be mounted as it is
> not treated as a continuation of the previous component.
>
> Lucas
>
>
> > On 4 Dec 2014, at 19:29, Colin Yates <[email protected]> wrote:
> >
> > Hi all,
> >
> > I am seeing a component consistently unmount/remount every time the
> > application state changes. If I change the local state instead then it
> > doesn't umount but simply re-renders as I expected.
> >
> > I didn't expect changes in app-state to cause an unmount/remount only a
> > re-render (as that is my understanding of React's lifecycle). Further,
> > since I am talking about this my assumption (and the behaviour I am seeing)
> > is that om will only call the render protocol method if the values have
> > actually changed.
> >
> > If my assumptions are correct I will see if I can reduce the problem into a
> > simple gist.
> >
> > The reason this is a pain, performance aside, is because a re-mount loses
> > focus and this specific component is a text field. I notice in the
> > discussion on text-fields in the Basic tutorial "text" is component local,
> > maybe now I understand why as this seemed to me to go against the grain of
> > what is advised to go into local state...
> >
> > Can somebody please clarify?
> >
> > Thanks!
> >
> > --
> > Note that posts from new members are moderated - please be patient with
> > your first post.
> > ---
> > You received this message because you are subscribed to the Google Groups
> > "ClojureScript" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> > To post to this group, send email to [email protected].
> > Visit this group at http://groups.google.com/group/clojurescript.
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.