A runnable Expo app that demonstrates how @askable-ui/react-native captures mobile UI context.
- Shared
AskableContextcreated withuseAskable() - Screen-level context updates with
useAskableScreen()and React Navigation'suseIsFocused() - Raw
ScrollViewmeasurement-driven context updates withuseAskableScrollView() - Visibility-driven list context updates with
useAskableVisibility() - Press-driven focus updates with
<Askable>wrappers aroundPressablecards - A live prompt preview panel showing what an AI layer would receive
cd examples/react-native-expo
npm install
npm run startThen open the project in Expo Go, an iOS simulator, or an Android emulator.
- Launch the app on the Dashboard screen.
- Scroll the dashboard and watch the leading metric card update context through
useAskableScrollView(). - Tap a metric card like Revenue to refine the prompt context further.
- Open the Insights screen.
- Notice the screen-level context changes because
useAskableScreen()is bound to navigation focus. - Scroll the insights list and watch the leading visible card update context through
useAskableVisibility(). - Tap an insight action card to further refine the prompt context.
const { ctx, promptContext } = useAskable({ name: 'react-native-example' });
const isFocused = useIsFocused();
useAskableScreen({
ctx,
active: isFocused,
meta: { screen: 'Dashboard', section: 'overview' },
text: 'Dashboard overview screen',
});
const { onScroll, createOnItemLayout } = useAskableScrollView({
ctx,
active: isFocused,
getMeta: (card) => ({ ...card.meta, visible: true, source: 'scrollview-measurement' }),
getText: (card) => `${card.title} is currently leading the dashboard scroll view`,
});
<ScrollView onScroll={onScroll} scrollEventThrottle={16}>
{dashboardCards.map((card) => (
<Askable key={card.title} ctx={ctx} meta={card.meta} text={card.text}>
<Pressable onLayout={createOnItemLayout(card.title, card)}>{/* ... */}</Pressable>
</Askable>
))}
</ScrollView>;See App.tsx for the complete example.