10.0.0-alpha.1 - Component overwrites property/method at `t` key
See original GitHub issueI have components that look roughly like this:
class MyComponent extends Component {
t (input) {
return translated(input);
}
render () {
return <div>${this.t('whatever')}</div>;
}
}
After upgrading to 10.0.0-alpha.1, they all started failing to render. I checked the value of this.t
and found that it was false
instead of a reference to the method. I have not looked into where/how it was set, or if there are any other properties overwrites I didn’t expect. I was able to fix by renaming to tr
.
Generally, if preact sets property keys on elements, I’d expect them to be a little more obfuscated. Or if there’s a list of reserved keys, that would help, I suppose–maybe make a rule of no one-letter methods? I guess this is likely from aggressive minification? If so, is that a possible conflict with aggressive minification of larger bundles? (Since they may perform the same operation to rename instance properties.)
I have a sandbox for this, but it seems to be having trouble fetching the 10.0.0-alpha.1 dep for me. https://codesandbox.io/s/lpqj1lw12m Hopefully it works later, or this is easy to test/repro.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
This is probably fixed with #1377 . My guess is that our minifier turned
this._force
intothis.t
because we set that tofalse
on each state update.Alpha 2 is out 🎉