Skip to content

Instantly share code, notes, and snippets.

name expo-ui-doc-screenshots
description Add hero screenshots to Expo UI SwiftUI / Jetpack Compose component docs. Renders the example in bare-expo, captures both light and dark mode, embeds via the theme-aware ComponentDiagram with a fixed 3:2 or 9:16 canvas (zero CLS).

When to use

User wants to add a hero image to an @expo/ui component doc page so users see the component as soon as the page loads. Each component gets two screenshots (light and dark) that swap automatically based on the docs site's theme.

Paths

@intergalacticspacehighway
intergalacticspacehighway / SyncTextInputValidation.tsx
Last active May 10, 2026 03:30
Synchronous validation with React Native TextInput
import { TextInput } from 'react-native';
import Animated, {
useAnimatedRef,
useHandler,
dispatchCommand,
useEvent,
} from 'react-native-reanimated';
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
@intergalacticspacehighway
intergalacticspacehighway / CollapsibleText.tsx
Last active April 27, 2025 14:08
Collapsible text using reanimated
import { useEffect, useRef } from "react";
import { View } from "react-native";
import Animated, {
useAnimatedStyle,
useSharedValue,
} from "react-native-reanimated";
// Example
export default function App() {
@intergalacticspacehighway
intergalacticspacehighway / gist:ad67264c41f65d52f11ef95e5934d50d
Last active November 13, 2023 19:14
Streaming text request in React Native PoC
import Networking from "react-native/Libraries/Network/RCTNetworking.ios";
// Same import from .android
// import Networking from "react-native/Libraries/Network/RCTNetworking.android";
let streamingServer = "Streaming Server URL";
let requestId = null;
@intergalacticspacehighway
intergalacticspacehighway / FlatListGapExample.jsx
Created February 28, 2023 01:14
Add gap in FlatList items with numColumns
import {Dimensions, FlatList, View} from 'react-native';
const screenWidth = Dimensions.get('window').width;
const numColumns = 2;
const gap = 5;
const availableSpace = screenWidth - (numColumns - 1) * gap;
const itemSize = availableSpace / numColumns;
const renderItem = ({item}) => {
@intergalacticspacehighway
intergalacticspacehighway / keyboard-aware-reanimated-scrollview.tsx
Last active August 20, 2025 18:53
keyboard aware reanimated scrollview
import React from "react";
import { Dimensions, TextInput, ScrollView } from "react-native";
import Animated, {
useAnimatedKeyboard,
useAnimatedReaction,
runOnJS,
KeyboardState,
useAnimatedProps,
useAnimatedScrollHandler,
@intergalacticspacehighway
intergalacticspacehighway / use-fetch-on-app-foreground.tsx
Created January 28, 2022 04:10
app fetch request failing in background
import { useEffect, useRef } from "react";
import { AppState, AppStateStatus } from "react-native";
export const useFetchOnAppForeground = () => {
const listener = useRef(null);
function fetchOnAppForeground(params) {
if (AppState.currentState === "active") {
return fetch(params);
} else {
@intergalacticspacehighway
intergalacticspacehighway / viewability-tracker-flatlist.tsx
Last active July 24, 2025 06:38
Viewability tracker with shared values
import { createContext, forwardRef, useCallback, useMemo } from "react";
import { FlatList, FlatListProps, ViewToken } from "react-native";
import Animated, { useSharedValue } from "react-native-reanimated";
const MAX_VIEWABLE_ITEMS = 4;
type ViewabilityItemsContextType = string[];
export const ViewabilityItemsContext = createContext<
Animated.SharedValue<ViewabilityItemsContextType>
@intergalacticspacehighway
intergalacticspacehighway / react-native+0.64.3.patch
Last active January 21, 2022 04:38
React native flex gap patch - only works on iOS
diff --git a/node_modules/react-native/Libraries/Components/View/ReactNativeViewViewConfig.js b/node_modules/react-native/Libraries/Components/View/ReactNativeViewViewConfig.js
index 4d6f0dd..e120116 100644
--- a/node_modules/react-native/Libraries/Components/View/ReactNativeViewViewConfig.js
+++ b/node_modules/react-native/Libraries/Components/View/ReactNativeViewViewConfig.js
@@ -13,104 +13,104 @@ import ReactNativeViewViewConfigAndroid from './ReactNativeViewViewConfigAndroid
import {Platform} from 'react-native';
const ReactNativeViewConfig = {
- uiViewClassName: 'RCTView',
+ uiViewClassName: "RCTView",
@intergalacticspacehighway
intergalacticspacehighway / App.tsx
Created January 7, 2022 06:18
Add row/col gaps in flatlist
function App() {
const data = Array(10).fill(0);
const GAP = 5;
const numColumns = 3;
const { width } = Dimensions.get("window");
// Reduce the size to accomodate margin space by items
const ITEM_SIZE = width / numColumns - ((numColumns - 1) * GAP) / numColumns;
const renderItem = ({ index }) => {