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.

New rule request: require-each-key

See original GitHub issue

We were having huge performance issues in our projects when rendering table rows.

In our case, a single change to a single table cell was causing all rows to rerender, which was blocking the main thread for up to more than a second.

After an investigation I found out that it was a problem with how we use {{#each}}.

After we added key to all our eaches, Ember stopped rerendering all rows, but only the ones that actually needed to be updated.

For example, in one of the cases (selecting a table row via clicking a checkbox) resulted in a 10x performance increase (from ~300 ms down to ~30 ms).

This is applicable not only to tables, but to any usage of {{#each}}.

I would like to have a rule that will require to always use key with {{#each}}.

Examples of valid code:

{{#each this.items key="id" as |item|}}
  {{item.name}}
{{/each}}
{{#each this.items key="deeply.nested.id" as |item|}}
  {{item.name}}
{{/each}}
{{#each this.items key="@index" as |item|}}
  {{item.name}}
{{/each}}
{{#each this.items key="@identity" as |item|}}
  {{item.name}}
{{/each}}

Examples of invalid code:

{{#each this.items as |item|}}
  {{item.name}}
{{/each}}
{{#each this.items key="@invalid" as |item|}}
  {{item.name}}
{{/each}}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
EvgenyOrekhovcommented, Sep 18, 2020

@rajasegar According to the documentation, the only valid “special” keys (with the @ symbol) are @index and @identity.

0reactions
EvgenyOrekhovcommented, Sep 18, 2020

Added key="deeply.nested.id" example to the issue description.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ember-template-lint/require-each-key.md at master - GitHub
ember-template-lint/docs/rule/require-each-key.md ... array is map-ed over, it will produce an new array with completely different objects between renders.
Read more >
ember-template-lint - npm
When the ember-template-lint executable is run, we would have a single result indicating that the no-bare-strings rule found an error.
Read more >
Beneficial Ownership Information Reporting Requirements
FinCEN is issuing a final rule requiring certain entities to file with FinCEN reports that identify two categories of individuals: the ...
Read more >
ember-template-lint/README.md - UNPKG
21, This addon is installed by default with new Ember apps, so check your package.json before installing to see if you ... docs/rule/require-each-key.md)...
Read more >
Florida Supreme Court Issues New Format Requirements for ...
The new rule amends Rule 1.280 to require litigants to state the deposition question, interrogatory, or discovery request followed by the ...
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