Preact: componentWillUnmount (still) failing to fire

Created on 11 Nov 2016  路  13Comments  路  Source: preactjs/preact

Follow up to #373

Here's a reproduction with componentWillUnmount not firing in 6.4.0:
http://jsfiddle.net/j1xkyjcL/3/

has fix

All 13 comments

Hi Garth,

The issue you found happens when switching from a component to an element with the same nodeName the component had previously rendered. Luckily, it will be fixed in the next patch release (7.0.2)! Here's a preview of it working:

6a4479a7ea5ff5cc46cff44015447b86

Amazing! Thank you

@developit running into this alot in our app. is there a branch available to test this fix? Thanks

Just released 7.0.2, which contains the fix. npm i -S preact@beta.

Here's the above demo working against 7.0.2:
http://jsfiddle.net/developit/j1xkyjcL/5/

Awesome thanks 馃憤 will give it a test and see if it resolves our issues

@developit Unfortunately we still experiencing this issue in 7.0.2.
Have extracted out a fiddle http://jsfiddle.net/fm7v186v/47/ removing as much app specific stuff as possible. The Sibling component ends up Calling componentDidMount twice and componentWillUnmount never gets call.

@cloudkite looks like a separate issue, but we can track it here. I'm looking into a fix.

@developit thanks! Have tried 7.0.3 out and I now get an infinite rerender loop. Will see if I can reproduce in a fiddle. Its not too bad as I can workaround it. Changing a particular component from a functional component -> class component seems to avoid the infinite loop

Hmm - strange. I'll try to get 7.1.0 out quickly as it'll likely affect that.

@developit tried it on 7.1.0 no longer causes an infinite loop 馃憤. However I now get this error when I change the misbehaving component from a PureComponent -> function. As before works fine as a PureComponent

preact.js:231 Uncaught (in promise) DOMException: Failed to execute 'appendChild' on 'Node': The new child element contains the parent.
    at innerDiffNode (webpack:///./~/preact/dist/preact.js?:231:59)
    at idiff (webpack:///./~/preact/dist/preact.js?:196:57)
    at diff (webpack:///./~/preact/dist/preact.js?:157:19)
    at renderComponent (webpack:///./~/preact/dist/preact.js?:326:32)
    at setComponentProps (webpack:///./~/preact/dist/preact.js?:284:103)
    at renderComponent (webpack:///./~/preact/dist/preact.js?:310:102)
    at rerender (webpack:///./~/preact/dist/preact.js?:72:46)

let me know if you need anything else. Thanks!

@cloudkite Just a standard preact-compat PureComponent? Interesting, need to look into that. I wonder if it's related to the IE test failure I saw.

@developit yup just standard PureComponent

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jescalan picture jescalan  路  3Comments

mizchi picture mizchi  路  3Comments

skaraman picture skaraman  路  3Comments

SabirAmeen picture SabirAmeen  路  3Comments

simonjoom picture simonjoom  路  3Comments