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

Immutable props fix (fixes #2433) #2779

Merged
merged 3 commits into from
Jan 5, 2021
Merged

Immutable props fix (fixes #2433) #2779

merged 3 commits into from
Jan 5, 2021

Conversation

claviska
Copy link
Contributor

This fixes a longstanding bug where the warning for immutable prop changes doesn't get shown. It also adds tests to ensure the warning is emitted at the correct times.

Side note: this will probably confuse people once it gets merged because a lot of projects are likely changing props without the { mutable: true } flag. I've already noticed a few in Stencil Router. 😆

@claviska claviska added the bug label Dec 23, 2020
@claviska claviska self-assigned this Dec 23, 2020
@claviska claviska mentioned this pull request Dec 23, 2020
@claviska claviska merged commit 9c18fa0 into master Jan 5, 2021
@NRaf
Copy link

NRaf commented Feb 11, 2021

@claviska Just updated to Stencil 2.4.0 and noticed this warning starting to come through my unit tests. I'm not actually mutating any props through my component logic, however, I do mutate props in my unit tests. Is there any way to disable the warning during tests? Or is there a recommended alternative?

@adamdbradley adamdbradley deleted the immutable-props-fix branch February 26, 2021 18:50
@allinne
Copy link

allinne commented Mar 31, 2021

My unit tests pass even in 2.0.1 with an error:
@Prop() "state" on <my-component> is immutable but was modified from within the component.
The test looks like:

const myComponent = new MyComponent();
myComponent.state = 'error';

To pass the tests I needed make all props mutable but it is not the right way. Please, clarify this moment.

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

Successfully merging this pull request may close these issues.

Props are immutable by default but still able to manipulate without mentioning mutable: true
3 participants