Ramonda

unkeyable-memoized-argument

This fails the run. Where it is wrong about your code, // ramonda-check-ignore <reason> on the line says so, and the reason is printed on every run.

Reported when a @memoized is called with — or declared to take — something a cache key cannot hold: a key holds a string, a number or a boolean.

The framework reports the same fault while running, as RMD047 — but only once the line actually runs. This is the same fault proved from the source instead.

@memoized caches by its arguments, and a key can hold a string, a number or a boolean. An object cannot: comparing it by value is not something the cache can do, and keying on its identity would miss every time — a fresh object per render fills the map and hands back a new handler on every pass, which is the churn the decorator exists to prevent.

Pass the primitive the object stands for — row.id rather than row — and read the rest inside the handler, where this is in scope anyway.

Development throws, so this is not shipped by anybody who ran the branch. Production builds the handler and moves on WITHOUT caching that call: the page works and only the memoisation is lost, silently — which is why it is worth saying before anything runs.

An argument this cannot read is left alone. this.pick(row.id) and this.pick(row) look the same from here, and reporting a maybe is the one thing this package will not do.

Next