The StorytellerCardView renders a single, adaptive Storyteller card for a given clips collection. It automatically measures its content and updates its height accordingly.
Initialize the SDK before mounting the card. A newly mounted card begins loading from its configuration; use onDataLoadCompleted for success and error handling. It starts at zero height until native content measurements arrive.
configuration.context adds string key/value analytics context to this card.
onDataLoadCompleted receives success, error and dataCount. iOS reports 1 on successful card loading and 0 on failure; do not interpret this as the number of items in the collection.
Card does not expose onDataLoadStarted; show initial loading UI from your own mount state if needed.
The card updates its height when the displayed content changes, including after a card action changes the ordering within its collection.
Changing collectionId starts a new card instance; the previous collection’s measured height is not reused.
A Card's heading, subheading and button title fonts, and their OpenType font features such as ss02, are configured in the CMS rather than in your app's theme. Your app only needs to bundle the fonts the CMS refers to:
Android: add each font to android/app/src/main/res/font/ using the exact resource name the CMS returns, for example knockout_67.otf for knockout_67. Fonts placed only in android/app/src/main/assets/fonts/ are not used for Card fonts from the CMS.
iOS: register the font in your app as usual. The font name configured in the CMS must match the registered font name.
If the requested font can't be found, the Card uses your theme font without the font features. Font features only apply when the bundled font supports them.
Ensure the parent layout allows the card to expand vertically; the component sets its own height based on content.
Call reloadData() when you know content or configuration has changed.
{"slug": "storyteller-card-view", "page_title": "Card Component", "page_url": "StorytellerCardView/", "canonical_url": "/react-native/StorytellerCardView/", "markdown": "# Card Component\n\nThe `StorytellerCardView` renders a single, adaptive Storyteller card for a given clips collection. It automatically measures its content and updates its height accordingly.\n\nInitialize the SDK before mounting the card. A newly mounted card begins loading from its configuration; use `onDataLoadCompleted` for success and error handling. It starts at zero height until native content measurements arrive.\n\n## Props\n\n```ts\nimport type { StyleProp, ViewStyle } from 'react-native';\nimport type { DataLoadCompletedEvent, StorytellerAnalyticsContext } from '@getstoryteller/react-native-storyteller-sdk';\n\ntype Props = {\n configuration: {\n collectionId: string; // required\n context?: StorytellerAnalyticsContext; // string key/value analytics context\n };\n style?: StyleProp<ViewStyle>;\n onDataLoadCompleted?: (event: DataLoadCompletedEvent) => void;\n};\n```\n\n### Notes\n\n- `configuration.collectionId` is required.\n- `configuration.context` adds string key/value analytics context to this card.\n- `onDataLoadCompleted` receives `success`, `error` and `dataCount`. iOS reports `1` on successful card loading and `0` on failure; do not interpret this as the number of items in the collection.\n- Card does not expose `onDataLoadStarted`; show initial loading UI from your own mount state if needed.\n- The card updates its height when the displayed content changes, including after a card action changes the ordering within its collection.\n- Changing `collectionId` starts a new card instance; the previous collection\u2019s measured height is not reused.\n\n## Fonts from the CMS\n\nA Card's heading, subheading and button title fonts, and their OpenType font features such as `ss02`, are configured in the CMS rather than in your app's theme. Your app only needs to bundle the fonts the CMS refers to:\n\n- **Android:** add each font to `android/app/src/main/res/font/` using the exact resource name the CMS returns, for example `knockout_67.otf` for `knockout_67`. Fonts placed only in `android/app/src/main/assets/fonts/` are not used for Card fonts from the CMS.\n- **iOS:** register the font in your app as usual. The font name configured in the CMS must match the registered font name.\n\nIf the requested font can't be found, the Card uses your theme font without the font features. Font features only apply when the bundled font supports them.\n\n## Methods\n\n`StorytellerCardView` exposes an imperative API via a ref:\n\n- `reloadData()` \u2014 Reloads the card\u2019s data.\n\n## Usage\n\n```tsx\nimport React, { useRef } from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport {\n StorytellerCardView,\n type StorytellerCardViewInterface,\n type DataLoadCompletedEvent,\n} from '@getstoryteller/react-native-storyteller-sdk';\n\nexport default function CardExample() {\n const cardRef = useRef<StorytellerCardViewInterface>(null);\n\n const handleDataLoadCompleted = (event: DataLoadCompletedEvent) => {\n if (event.success) {\n console.log('Card loaded. Items:', event.dataCount);\n } else {\n console.warn('Card load error:', event.error);\n }\n };\n\n const refresh = () => cardRef.current?.reloadData();\n\n return (\n <View style={styles.container}>\n <StorytellerCardView\n ref={cardRef}\n configuration={{ collectionId: 'your-collection-id' }}\n style={styles.card}\n onDataLoadCompleted={handleDataLoadCompleted}\n />\n <\/View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n card: { width: '100%' },\n});\n```\n\n### Tips\n\n- Ensure the parent layout allows the card to expand vertically; the component sets its own height based on content.\n- Call `reloadData()` when you know content or configuration has changed.\n", "copy_markdown_include_header": false, "base_path": "", "ai_dir": "ai", "missing_payload_behavior": "empty"}