Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ A benchmark suite for evaluating how coding models solve real React Native tasks

## Available Evals

Groups map to top-level folders under `evals/`. The current suite contains 134 evals.
Groups map to top-level folders under `evals/`. The current suite contains 139 evals.

| Group | Path | Evals | Status |
| ----------------- | ------------------------- | ----: | ------ |
| animation | `evals/animation` | 13 | Active |
| async-state | `evals/async-state` | 13 | Active |
| async-state | `evals/async-state` | 18 | Active |
| expo-router | `evals/expo-router` | 11 | Active |
| expo-sdk | `evals/expo-sdk` | 25 | Active |
| expo-ui | `evals/expo-ui` | 7 | Active |
Expand Down
4 changes: 4 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import React from 'react'
import { Pressable, StyleSheet, Text, View } from 'react-native'

type FeedStatus = 'idle' | 'loading' | 'success' | 'error'

export default function App() {
const status = 'idle'
const items = [] as string[]

const statusContent = {
idle: <Text style={styles.meta}>Tap fetch to start.</Text>,
loading: <Text style={styles.meta}>Loading feed…</Text>,
success: items.map((item) => (
<View key={item} style={styles.item}>
<Text>{item}</Text>
</View>
)),
error: (
<View style={styles.errorCard}>
<Text style={styles.errorText}>Error</Text>
<Pressable onPress={() => {}} style={styles.retryButton}>
<Text style={styles.retryButtonText}>Retry</Text>
</Pressable>
</View>
),
} satisfies Record<FeedStatus, React.ReactNode>

return (
<View style={styles.screen}>
<Text style={styles.title}>Feed</Text>

<View style={styles.row}>
<Pressable onPress={() => {}} style={styles.button}>
<Text style={styles.buttonText}>Fetch feed</Text>
</Pressable>

<Pressable onPress={() => {}} style={styles.buttonSecondary}>
<Text style={styles.buttonSecondaryText}>Reset</Text>
</Pressable>
</View>

<Text style={styles.meta}>Status {status}</Text>

{statusContent[status]}
</View>
)
}

const styles = StyleSheet.create({
button: {
backgroundColor: '#0f172a',
borderRadius: 8,
paddingHorizontal: 12,
paddingVertical: 10,
},
buttonSecondary: {
backgroundColor: '#e2e8f0',
borderColor: '#94a3b8',
borderRadius: 8,
borderWidth: 1,
paddingHorizontal: 12,
paddingVertical: 10,
},
buttonSecondaryText: {
color: '#334155',
fontWeight: '600',
},
buttonText: {
color: '#fff',
fontWeight: '600',
},
errorCard: {
backgroundColor: '#fee2e2',
borderRadius: 10,
marginTop: 10,
padding: 12,
},
errorText: {
color: '#b91c1c',
},
item: {
backgroundColor: '#fff',
borderRadius: 8,
marginTop: 8,
paddingHorizontal: 12,
paddingVertical: 10,
},
meta: {
color: '#334155',
marginTop: 8,
},
retryButton: {
alignSelf: 'flex-start',
backgroundColor: '#b91c1c',
borderRadius: 8,
marginTop: 10,
paddingHorizontal: 12,
paddingVertical: 8,
},
retryButtonText: {
color: '#fff',
fontWeight: '600',
},
row: {
flexDirection: 'row',
gap: 8,
marginTop: 8,
},
screen: {
backgroundColor: '#f1f5f9',
flex: 1,
paddingHorizontal: 14,
paddingTop: 56,
},
title: {
color: '#0f172a',
fontSize: 24,
fontWeight: '700',
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Using Legend State v3, build a feed screen with an explicit async action lifecycle (idle, loading, success, error) driven by store actions.
Keep feed state in a Legend State observable store, write lifecycle transitions from the fetch action, and read state in components through tracked hooks.

Use this endpoint pattern:

- Feed items `https://dummyjson.com/todos?limit=<limit>&skip=<skip>`

Use this response shape:

- `{ "todos": [{ "id": number, "todo": string, "completed": boolean }] }`
- Map feed entries from `todo`

Example URL:

- `https://dummyjson.com/todos?limit=3&skip=0`
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
import React from 'react'
import { Pressable, StyleSheet, Text, View } from 'react-native'
import { observable } from '@legendapp/state'
import { useValue } from '@legendapp/state/react'

type FeedStatus = 'idle' | 'loading' | 'success' | 'error'

type FeedState = {
errorMessage: string | null
items: string[]
status: FeedStatus
}

const INITIAL_FEED_STATE: FeedState = {
errorMessage: null,
items: [],
status: 'idle',
}

const feed$ = observable<FeedState>({ ...INITIAL_FEED_STATE })

async function fetchFeedItems(endpoint: string): Promise<string[]> {
const response = await fetch(endpoint)

if (!response.ok) {
throw new Error(`Request failed with status ${response.status}`)
}

const json = (await response.json()) as {
todos: Array<{ id: number; todo: string }>
}

return json.todos.map((item) => item.todo)
}

const fetchFeed = async () => {
feed$.errorMessage.set(null)
feed$.status.set('loading')

try {
const items = await fetchFeedItems(
'https://dummyjson.com/todos?limit=3&skip=0'
)
feed$.items.set(items)
feed$.status.set('success')
} catch (error) {
feed$.errorMessage.set(
error instanceof Error ? error.message : 'Unknown error'
)
feed$.status.set('error')
}
}

const resetFeed = () => {
feed$.set({ ...INITIAL_FEED_STATE })
}

export default function App() {
const status = useValue(feed$.status)
const items = useValue(feed$.items)
const errorMessage = useValue(feed$.errorMessage)

const statusContent = {
idle: <Text style={styles.meta}>Tap fetch to start.</Text>,
loading: <Text style={styles.meta}>Loading feed…</Text>,
success: items.map((item) => (
<View key={item} style={styles.item}>
<Text>{item}</Text>
</View>
)),
error: (
<View style={styles.errorCard}>
<Text style={styles.errorText}>{errorMessage}</Text>
<Pressable onPress={() => void fetchFeed()} style={styles.retryButton}>
<Text style={styles.retryButtonText}>Retry</Text>
</Pressable>
</View>
),
} satisfies Record<FeedStatus, React.ReactNode>

return (
<View style={styles.screen}>
<Text style={styles.title}>Feed</Text>

<View style={styles.row}>
<Pressable onPress={() => void fetchFeed()} style={styles.button}>
<Text style={styles.buttonText}>Fetch feed</Text>
</Pressable>

<Pressable onPress={resetFeed} style={styles.buttonSecondary}>
<Text style={styles.buttonSecondaryText}>Reset</Text>
</Pressable>
</View>

<Text style={styles.meta}>Status {status}</Text>

{statusContent[status]}
</View>
)
}

const styles = StyleSheet.create({
button: {
backgroundColor: '#0f172a',
borderRadius: 8,
paddingHorizontal: 12,
paddingVertical: 10,
},
buttonSecondary: {
backgroundColor: '#e2e8f0',
borderColor: '#94a3b8',
borderRadius: 8,
borderWidth: 1,
paddingHorizontal: 12,
paddingVertical: 10,
},
buttonSecondaryText: {
color: '#334155',
fontWeight: '600',
},
buttonText: {
color: '#fff',
fontWeight: '600',
},
errorCard: {
backgroundColor: '#fee2e2',
borderRadius: 10,
marginTop: 10,
padding: 12,
},
errorText: {
color: '#b91c1c',
},
item: {
backgroundColor: '#fff',
borderRadius: 8,
marginTop: 8,
paddingHorizontal: 12,
paddingVertical: 10,
},
meta: {
color: '#334155',
marginTop: 8,
},
retryButton: {
alignSelf: 'flex-start',
backgroundColor: '#b91c1c',
borderRadius: 8,
marginTop: 10,
paddingHorizontal: 12,
paddingVertical: 8,
},
retryButtonText: {
color: '#fff',
fontWeight: '600',
},
row: {
flexDirection: 'row',
gap: 8,
marginTop: 8,
},
screen: {
backgroundColor: '#f1f5f9',
flex: 1,
paddingHorizontal: 14,
paddingTop: 56,
},
title: {
color: '#0f172a',
fontSize: 24,
fontWeight: '700',
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 1
inputs:
files:
- app/App.tsx
requirements:
- id: legend-state-observable-store
description: Feed state lives in a store created with `observable` from `@legendapp/state`
- id: components-read-through-tracked-hooks
description: Components read observable state through a tracked hook (`useValue` or `use$`) or an `observer` wrapper from `@legendapp/state/react` rather than bare `.get()` calls in untracked render code
- id: async-action-sets-loading-before-await
description: Async fetch action writes loading status through an observable write (`.set` or `.assign`) before awaiting network work
- id: async-action-writes-success-data
description: Async fetch action writes fetched items and success status through an observable write (`.set` or `.assign`) in its success path
- id: async-action-writes-error-state
description: Async fetch action writes error state through an observable write (`.set` or `.assign`) in a separate failure path
- id: feed-fetches-todos-endpoint-and-maps-todo-field
description: Fetch action requests the `https://dummyjson.com/todos` endpoint pattern and maps feed entries from the `todo` field
- id: retry-path-calls-same-action
description: Error UI retry trigger calls the same async action used by initial fetch
- id: status-driven-ui-branching
description: UI output branches by lifecycle status values for idle loading success and error
Loading