-
Notifications
You must be signed in to change notification settings - Fork 795
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
Props are immutable by default but still able to manipulate without mentioning mutable: true #2433
Comments
I have the same issue. Stencil version:
|
Here's another example: import { Component, Prop, h } from '@stencil/core';
@Component({
tag: 'my-component',
styleUrl: 'my-component.css',
shadow: true,
})
export class MyComponent {
@Prop({ mutable: true }) isMutable = 'is mutable';
@Prop({ mutable: false }) isNotMutable = 'is not mutable';
render() {
return (
<div>
<p>
Is Mutable: {this.isMutable}
<br />
Is Not Mutable: {this.isNotMutable}
</p>
<button type="button" onClick={() => (this.isMutable = 'foo')}>
Set isMutable to 'foo'
</button>
<button type="button" onClick={() => (this.isNotMutable = 'bar')}>
Set isNotMutable to 'bar'
</button>
</div>
);
}
} I don't believe Stencil can actually enforce immutability, but you should see a warning in dev mode when the immutable prop is changed. This doesn't appear to be happening in 2.3.0. |
Closed
claviska
added a commit
that referenced
this issue
Dec 23, 2020
claviska
added a commit
that referenced
this issue
Jan 5, 2021
* fix(): show warning when immutable props change (fixes #2433) * test(): add tests for immutable prop warning
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Been stuck where documentation refers props are immutable by nature but explicitly we can set them mutable by assigning mutable:true, but in my case i can still change the prop value without setting mutable property,
Instead of showing "Hello Everyone!!" as output it shows kkkk
The text was updated successfully, but these errors were encountered: