Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using with mut results in render error #11

Open
tstormk opened this issue Aug 2, 2019 · 5 comments
Open

Using with mut results in render error #11

tstormk opened this issue Aug 2, 2019 · 5 comments

Comments

@tstormk
Copy link

tstormk commented Aug 2, 2019

Hello!

Say I have a component Test:
components/test/template.hbs
<div {{did-insert (fn (mut this.element))}} {{will-destroy (fn (mut this.element) null)}} />

When that component is destroyed, it results in the following error:
You modified "element" twice on [object Object] in a single render. It was rendered in undefined and modified in undefined. [...]

If I instead perform the registering/unregistering like so:
components/test/template.hbs
<div {{did-insert this.register}} {{will-destroy this.unregister}} />

components/test/component.js

@action
register(element) {
  this.element = element;
}

@action
unregister() {
  this.element = null;
}

Destroying the component doesn't result in an error.

This happens when mut-ing any property with any value on destroy, by the way, not just an element or a property that has been set before.

For reference, here's the code I used to test it:

{{#if this.show}}
  <Test />
{{/if}}

<Button @onClick={{toggle-action 'show' this}}>Toggle</Button>

Also, I'm not sure it makes any difference, but I'm on a canary build of Ember:
"ember-source": "https://s3.amazonaws.com/builds.emberjs.com/canary/shas/55f876ebc10bd1645e1e62fc5e0408266952259b.tgz"
"ember-cli": "github:ember-cli/ember-cli#ba9e3ea9bcad1c6e2299e40fe265cffe61d7a25b"

Any help would be appreciated!

UPDATE: It works if I use the action helper instead of fn. It also passes if I use ember-fn-helper-polyfill for fn. If I use the Ember 3.11 version of fn however, it fails with the error specified above.

@rwjblue
Copy link
Member

rwjblue commented Aug 2, 2019

@tstormk - Hmm, seems somewhat surprising. Can you submit a failing test to this repo (it would make it a bit easier to dig into)? I think a rendering test would reproduce right?

@tstormk
Copy link
Author

tstormk commented Aug 28, 2019

@rwjblue Any news on this?

@yratanov
Copy link

@rwjblue hi. Can you please look at this issue again? It still happens in 3.18.

@yratanov
Copy link

it looks like it's rather fn problem: emberjs/ember.js#18804

@vijayendranj
Copy link

Hi, I'm seeing this error with Ember 3.25. any ideas to get around this issue? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants