To elaborate, here are the two macros I've started using: https://gist.github.com/travis/3ae268c059d22d0ea6ec
The first starts a transaction and only updates a value if the component is still mounted, ensuring we don't update the data model if the corresponding component has unmounted. The second starts a go loop that automatically dies when the component has unmounted. Travis On Tue, May 6, 2014 at 11:16 PM, Travis Vachon <[email protected]> wrote: > Is there any reason not to use isMounted? I notice it's not in the > externs file provided by react, but it is a documented part of the > ReactComponent api: > > http://facebook.github.io/react/docs/component-api.html > > I'm finding it easier to build reusable go-loop abstractions that > behave properly when I use isMounted - it lets me avoid adding the > same kill channel boilerplate in every component to which I'd like to > add a go-loop. I added > > /** > * @protected > */ > React.ReactComponent.prototype.isMounted = function() {}; > > to my externs file and it seems to be working well. > > Travis > > On Thu, May 1, 2014 at 5:56 PM, Daniel Kersten <[email protected]> wrote: >> Great, thanks! That makes a lot of sense and sounds quite useful. >> >> >> On 1 May 2014 20:35, Dylan Butman <[email protected]> wrote: >>> >>> IWillReceiveProps is trigged when component props change (cursor passed >>> into om/build). Not called on initial render >>> http://facebook.github.io/react/docs/component-specs.html >>> >>> This differs from IWillUpdate in that IWillUpdate is trigged when local >>> component state changes as well. In React, the convention is to use >>> willReceiveProps to update local state in response to prop changes. If you >>> were to change state in willUpdate you could cause an infinite loop (React >>> internals prevent this, but it's a bad idea!). >>> >>> I added IWillReceive props to the docs with a little more explanation on >>> the differences... >>> >>> -- >>> 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. -- 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.
