question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

10.0.0-alpha.1 - Component overwrites property/method at `t` key

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
marvinhagemeistercommented, Mar 14, 2019

This is probably fixed with #1377 . My guess is that our minifier turned this._force into this.t because we set that to false on each state update.

1reaction
marvinhagemeistercommented, Mar 14, 2019

Alpha 2 is out 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling keys · Issue #1388 · preactjs/preact · GitHub
Single elements/components aren't remounted when their key changes · Sometimes elements/components are remounted when they should be just reordered.
Read more >
Overriding properties in python - inheritance - Stack Overflow
Basically, ATimesTwo inherits the getter function from A but overrides the setter function. Does anybody know of a way to do this (in...
Read more >
Layers | Style Specification | Mapbox GL JS
A style's layers property lists all the layers available in that style. The type of layer is specified by the "type" property, and...
Read more >
react-i18next | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
material-ui/core/CHANGELOG.md - UNPKG
258, - [TypeScript] Allow lab components to have overrides in theme ... 702, - [test] Use method calls over property access expressions (#20545)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found