React Native Components
The Resync React Native SDK provides powerful components for rendering dynamic content.
ResyncCampaignView
Component for rendering campaign variants automatically.
Basic Usage
import { ResyncCampaignView } from 'resync-react-native';
export default function CheckoutScreen() {
return (
<ResyncCampaignView name="checkout_flow_test" />
);
}
Props
| Prop | Type | Required | Description |
|---|---|---|---|
name | string | ✅ | Name of the campaign |
loadingComponent | React.ReactNode | ❌ | Custom loading component |
errorComponent | React.ReactNode | ❌ | Custom error component |
emptyComponent | React.ReactNode | ❌ | Custom empty state component |
functionRegistry | FunctionRegistry | ❌ | Custom functions for element interactions |
navigationRegistry | NavigationRegistry | ❌ | Navigation functions for click actions |
logAnalytics | LogAnalytics | ❌ | Analytics logging function |
How It Works
ResyncCampaignView automatically:
- Calls
getVariant()to get the user's assigned variant - Tracks an impression
- Fetches the content view for that variant
- Renders it natively
No manual variant logic needed!
With Conversion Tracking
import Resync from 'resync-react-native';
export default function CheckoutScreen() {
const handlePurchase = async (orderId) => {
// Track conversion
await Resync.logEvent({
// If this is a campaign goal event, it will be registered as a conversion to the campaign
eventId: 'evt_purchase_completed', // campaign goal event created on the dashboard
metadata: {
orderId,
amount: 1000,
// any other data
}
});
};
return (
<Button title="Purchase" onPress={handlePurchase} />
);
}
ResyncContentView
Component for rendering regular content views (non-campaign content).
Basic Usage
import { ResyncContentView } from 'resync-react-native';
export default function HomeScreen() {
return (
<ResyncContentView name="WelcomeCard" />
);
}
Props
| Prop | Type | Required | Description |
|---|---|---|---|
name | string | ✅ | Name of the content view to render |
loadingComponent | React.ReactNode | ❌ | Custom loading component |
errorComponent | React.ReactNode | ❌ | Custom error component |
emptyComponent | React.ReactNode | ❌ | Custom empty state component |
functionRegistry | FunctionRegistry | ❌ | Custom functions for element interactions |
navigationRegistry | NavigationRegistry | ❌ | Navigation functions for click actions |
logAnalytics | LogAnalytics | ❌ | Analytics logging function |
With Custom Loading
import { ResyncContentView } from 'resync-react-native';
import { ActivityIndicator, View } from 'react-native';
export default function HomeScreen() {
return (
<ResyncContentView
name="WelcomeCard"
loadingComponent={
<View style={{ flex: 1, justifyContent: 'center' }}>
<ActivityIndicator size="large" />
</View>
}
/>
);
}
With Navigation
import { ResyncContentView } from 'resync-react-native';
import { useNavigation } from '@react-navigation/native';
export default function HomeScreen() {
const navigation = useNavigation();
const navigationRegistry = {
navigate: (routeName, params) => navigation.navigate(routeName, params),
push: (routeName, params) => navigation.push(routeName, params),
goBack: () => navigation.goBack(),
};
return (
<ResyncContentView
name="WelcomeCard"
navigationRegistry={navigationRegistry}
/>
);
}
With Custom Functions
import { ResyncContentView } from 'resync-react-native';
export default function FormScreen() {
const functionRegistry = {
handleFormSubmit: async (formData) => {
console.log('Form submitted:', formData);
await sendToAPI(formData);
},
handleButtonClick: (data) => {
console.log('Button clicked:', data);
},
};
return (
<ResyncContentView
name="ContactForm"
functionRegistry={functionRegistry}
/>
);
}
With Analytics
import { ResyncContentView } from 'resync-react-native';
import analytics from '@react-native-firebase/analytics';
export default function HomeScreen() {
const logAnalytics = (logId, event) => {
analytics().logEvent(event.type, {
logId,
...event,
});
};
return (
<ResyncContentView
name="WelcomeCard"
logAnalytics={logAnalytics}
/>
);
}
Content Types
Sections
Container components that hold other elements with flexible layouts.
Lists
Dynamic lists that can display data from static arrays or API endpoints.
Forms
Complete form rendering with validation, custom styling, and submission handling.
Elements
Individual UI components available:
- Text - Display text content
- Buttons - Interactive buttons with click actions
- Images - Display images from URLs
- Icons - SVG icons from Lucide
- Divider - Visual separators
- Inputs - Text, email, numeric, phone, password
- Select - Dropdown selections
- Checkboxes - Multiple selection inputs
- Radio Buttons - Single selection inputs
- Textareas - Multi-line text inputs
Complete Example
import React from 'react';
import { SafeAreaView, StyleSheet } from 'react-native';
import { ResyncContentView } from 'resync-react-native';
import { useNavigation } from '@react-navigation/native';
import analytics from '@react-native-firebase/analytics';
export default function OnboardingScreen() {
const navigation = useNavigation();
const navigationRegistry = {
navigate: (routeName, params) => navigation.navigate(routeName, params),
push: (routeName, params) => navigation.push(routeName, params),
goBack: () => navigation.goBack(),
};
const functionRegistry = {
handleOnboardingComplete: async (userData) => {
await saveUserData(userData);
navigation.navigate('Home');
},
};
const logAnalytics = (logId, event) => {
analytics().logEvent(event.type, {
logId,
screen: 'Onboarding',
...event,
});
};
return (
<SafeAreaView style={styles.container}>
<ResyncContentView
name="OnboardingFlow"
navigationRegistry={navigationRegistry}
functionRegistry={functionRegistry}
logAnalytics={logAnalytics}
/>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});