Open rramsey opened 1 week ago
@rramsey Thanks for the feedback! Mutable props is something we've gotten feedback on in the past and is a topic we need to analyze for the future. I'll get this labeled and link some related issues if you wanna check those out and have any feedback on them as well. Thanks again!
Relates to: #5644, #3490
No worries. I'm just glad I hadn't goofed up and been wrong. Although I wish I had found the other entries when I searched. Sorry for the sort-of dupe.
Honestly, the simplest solution would really be to just change the docs for now to let people know that this is in flux and that people should not rely on mutable: false being truly immutable.
@rramsey would you be open to take a stab at this and provide a PR to our docs project?
Prerequisites
Stencil Version
4.21.0
Current Behavior
The documentation at https://stenciljs.com/docs/properties#mutability says:
Creating a brand new StencilJS component still allows you to mutate a standard
Prop()
within a component. The component re-renders after the property is changed.Expected Behavior
I would expect the StencilJS build to fail and report an error that the component attempted to mutate an immutable property
Alternately, I would expect a console.error during development and the property not to change, and when built the property would only change if the value were changed in the Vue/Angular/Html app.
Worst case scenario, I would expect the documentation to say something like:
System Info
Steps to Reproduce
npm init stencil@latest
called prop-bug.cd prop-bug
and edit the package.json to use"@stencil/core": "^4.21.0",
and runnpm install
./src/components/my-component/my-component.tsx
file add an input field so the user can input a new value for this.first.npm install
andnpm start
Code Reproduction URL
https://github.com/rramsey/stencil-bug
Additional Information
The repo uses
But I see the same behavior with a simple: