### Expo Installation Source: https://github.com/marcuzgabriel/react-native-reanimated-skeleton/blob/main/README.md Instructions for installing and configuring the Skeleton component in an Expo project, addressing compatibility with react-native-linear-gradient. ```APIDOC ## Expo Install ### Description This section provides instructions for integrating the Skeleton component into an Expo project. It specifically addresses the compatibility issue with `react-native-linear-gradient` by outlining the necessary steps to use `expo-linear-gradient` instead, including a postinstall script. ### Steps 1. **Add Postinstall Script**: Ensure you have the provided postinstall script from the repository: [https://github.com/marcuzgabriel/react-native-reanimated-skeleton/tree/main/packages/expo/scripts](https://github.com/marcuzgabriel/react-native-reanimated-skeleton/tree/main/packages/expo/scripts) 2. **Configure package.json**: Add the postinstall script to your `package.json` file. Refer to the example provided: [https://github.com/marcuzgabriel/react-native-reanimated-skeleton/blob/main/packages/expo/package.json](https://github.com/marcuzgabriel/react-native-reanimated-skeleton/blob/main/packages/expo/package.json) 3. **Install Dependencies**: Run `npm install` and then restart your application. ### Import Transformation Example The postinstall script ensures that the following import transformation occurs: ```ts import LinearGradient from 'react-native-linear-gradient'; ... transforms into ... import { LinearGradient } from 'expo-linear-gradient'; ``` ``` -------------------------------- ### Enable Fade-In Animation for Content Source: https://context7.com/marcuzgabriel/react-native-reanimated-skeleton/llms.txt Set `hasFadeIn` to `true` to make the children container smoothly fade in from opacity 0 to 1 over 250ms when `isLoading` changes to `false`. This requires no additional setup. ```tsx import React, { useState, useEffect } from "react"; import { Text } from "react-native"; import Skeleton from "react-native-reanimated-skeleton"; export default function FadeInContent() { const [loading, setLoading] = useState(true); useEffect(() => { fetch("https://api.example.com/data") .then((res) => res.json()) .then(() => setLoading(false)); }, []); return ( Data loaded! ); // When loading becomes false, fades in over 250ms } ``` -------------------------------- ### Custom Layout with Shiver Animation Source: https://context7.com/marcuzgabriel/react-native-reanimated-skeleton/llms.txt Demonstrates a full example using a custom layout, shiver animation, and fade-in reveal for children. Configure animation type, direction, duration, colors, and bone geometry via props. ```tsx import React, { useState, useEffect } from "react"; import { Text, StyleSheet, SafeAreaView } from "react-native"; import Skeleton from "react-native-reanimated-skeleton"; // Full example: custom layout, shiver animation, fade-in reveal export default function ProfileCard() { const [isLoading, setIsLoading] = useState(true); useEffect(() => { // Simulate a network request const timer = setTimeout(() => setIsLoading(false), 2000); return () => clearTimeout(timer); }, []); return ( {/* Real content — shown when isLoading is false *//*} Jane Doe Senior Engineer ); } const styles = StyleSheet.create({ container: { alignItems: "center", padding: 20 }, name: { fontSize: 18, fontWeight: "bold" }, role: { fontSize: 14, color: "#666" }, }); ``` -------------------------------- ### Skeleton with Dynamic Loading State Source: https://github.com/marcuzgabriel/react-native-reanimated-skeleton/blob/main/packages/npm/README.md Control the visibility of the skeleton by dynamically updating the `isLoading` prop based on your application's state, such as data fetching status. This example shows how to sync `isLoading` with a React state variable. ```jsx export default function Placeholder () { const [loading, setLoading] = useState(true); return ( {...otherProps} /> ) } ``` -------------------------------- ### Customize Skeleton Animation Duration and Easing Source: https://context7.com/marcuzgabriel/react-native-reanimated-skeleton/llms.txt Control the animation speed with `duration` (in ms) and customize the timing curve using `easing` with a Reanimated `Easing` factory. The first example uses a fast shimmer with ease-in-out, and the second shows a slow, linear pulse. ```tsx import { Easing } from "react-native-reanimated"; import Skeleton from "react-native-reanimated-skeleton"; // Slow, linear pulse ``` -------------------------------- ### TypeScript Interface for Skeleton Props Source: https://context7.com/marcuzgabriel/react-native-reanimated-skeleton/llms.txt Utilize the exported `ISkeletonProps` interface from `react-native-reanimated-skeleton` to type wrapper components or custom skeleton factories. This example shows a reusable typed skeleton wrapper for card components. ```tsx import Skeleton, { ISkeletonProps } from "react-native-reanimated-skeleton"; // Reusable typed skeleton wrapper function CardSkeleton(props: Partial & { isLoading: boolean }) { const defaultLayout: ISkeletonProps["layout"] = [ { key: "img", width: "100%", height: 180, borderRadius: 12 }, { key: "title", width: 200, height: 18, borderRadius: 4, marginTop: 12 }, { key: "body", width: "100%", height: 14, borderRadius: 4, marginTop: 8 }, ]; return ( ); } // Usage ``` -------------------------------- ### Set Skeleton Bone and Highlight Colors Source: https://context7.com/marcuzgabriel/react-native-reanimated-skeleton/llms.txt Use `boneColor` and `highlightColor` to define the gradient stop colors for shiver animations or interpolation endpoints for pulse animations. The first example shows dark-mode colors, while the second demonstrates branded colors with a pulse animation. ```tsx import Skeleton from "react-native-reanimated-skeleton"; // Dark-mode skeleton // Branded skeleton (matches brand palette) ``` -------------------------------- ### Style Skeleton Container with `containerStyle` Source: https://context7.com/marcuzgabriel/react-native-reanimated-skeleton/llms.txt Use `containerStyle` to style the outer `View` that wraps both bones and children. The default styles are `{ alignItems: "center", flex: 1, justifyContent: "center" }`. This example demonstrates styling for a horizontal list-row container. ```tsx import Skeleton from "react-native-reanimated-skeleton"; // Horizontal list-row container ``` -------------------------------- ### Basic Skeleton Usage in Expo Source: https://context7.com/marcuzgabriel/react-native-reanimated-skeleton/llms.txt Demonstrates the basic usage of the Skeleton component in an Expo project. Ensure the postinstall script is run for Expo compatibility. ```tsx import React, { useState } from "react"; import Skeleton from "react-native-reanimated-skeleton"; export default function App() { const [loading] = useState(true); return ( ); } ``` -------------------------------- ### Expo Integration: Postinstall Script for Linear Gradient Source: https://context7.com/marcuzgabriel/react-native-reanimated-skeleton/llms.txt Expo does not natively support `react-native-linear-gradient`. A `postinstall` script in `package.json` is required to rewrite the import to `expo-linear-gradient` within `node_modules` before the package is used. ```json // packages/expo/package.json (excerpt) { "scripts": { "postinstall": "node scripts/postinstall.sh" }, "dependencies": { "expo-linear-gradient": "*", "react-native-reanimated-skeleton": "*" } } ``` ```bash # scripts/postinstall.sh rewrites the import inside node_modules: # FROM: import LinearGradient from 'react-native-linear-gradient'; ``` -------------------------------- ### Import Skeleton Component Source: https://github.com/marcuzgabriel/react-native-reanimated-skeleton/blob/main/packages/npm/README.md Import the Skeleton component from the library to use it in your project. ```javascript import Skeleton from "react-native-reanimated-skeleton"; ``` -------------------------------- ### Skeleton with Custom Layout Source: https://github.com/marcuzgabriel/react-native-reanimated-skeleton/blob/main/packages/npm/README.md Configure the skeleton's appearance by providing a `layout` prop with an array of objects, each defining the dimensions and margins for a bone. This is useful when you need precise control over the skeleton's structure. ```jsx export default function Placeholder() { return ( Your content Other content ); } ``` -------------------------------- ### Toggle Loading State with Skeleton Source: https://context7.com/marcuzgabriel/react-native-reanimated-skeleton/llms.txt Demonstrates how to control the skeleton's visibility using the `isLoading` prop. The skeleton renders when `isLoading` is true, and the children are shown when it's false. ```tsx import React, { useState } from "react"; import { Button, Text, View } from "react-native"; import Skeleton from "react-native-reanimated-skeleton"; export default function ToggleDemo() { const [isLoading, setIsLoading] = useState(false); return ( Content is ready!