# Feed shows an error state for every address: ReferenceError before initialization

> A .map() callback read a const declared a few lines further down. With an empty array the callback never runs, so tests and CI passed; with one item it threw inside the react-query queryFn and the screen showed its error state.

Web page: https://davidewins.com/errors/tdz-const-used-in-map-before-declaration

React Native. Confirmed fix, 25 September 2026.

Versions: TypeScript 5.9

Error:

```
ReferenceError: Cannot access 'scoreById' before initialization
```

## Cause

A `.map()` callback read a `const` declared a few lines further down. With an empty array the callback never runs, so tests and CI passed; with one item it threw inside the react-query queryFn and the screen showed its error state. TypeScript does not flag use-before-declaration inside a nested closure.

## Fix

Move the declaration above its first use. Add a test with at least one item, not only an empty list.

## More React Native errors

- [Screen crashes the whole app: Rendered more hooks than during the previous render](https://davidewins.com/errors/rules-of-hooks-usememo-after-early-return)
- [Screen crash: Maximum update depth exceeded](https://davidewins.com/errors/maximum-update-depth-competing-effects)
- [Reanimated crash on device: Tried to synchronously call a non-worklet function on the UI thread](https://davidewins.com/errors/worklet-calls-non-worklet-helper)
- [Rows wrapped in <Link asChild> collapse to a tiny height](https://davidewins.com/errors/link-aschild-function-style-dropped)
- [Pressable buttons render invisible: style function fill never applied](https://davidewins.com/errors/uniwind-pressable-double-wrap-drops-style)

[Search all errors](https://davidewins.com/errors)
