expoSnack/README.md
This directory contains a self-contained Expo Snack example that demonstrates the full capabilities of React Native Gifted Chat.
ExpoSnack.tsx from this repositoryApp.tsx content with the copied codeSimply copy ExpoSnack.tsx into your Expo project and ensure all dependencies are installed.
Add these dependencies to your Expo Snack or project:
{
"dependencies": {
"react-native-gifted-chat": "*",
"react-native-gesture-handler": "*",
"react-native-safe-area-context": "*",
"react-native-reanimated": "*",
"@expo/react-native-action-sheet": "*",
"@expo/vector-icons": "*",
"expo-image-picker": "*",
"expo-location": "*",
"expo-linking": "*",
"react-native-maps": "*",
"dayjs": "*"
}
}
This example showcases all major features of React Native Gifted Chat:
The example includes several customizable components that you can modify:
The app automatically adapts to your device's color scheme (light/dark mode). You can customize the colors in the styles object:
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff', // Light mode background
},
containerDark: {
backgroundColor: '#000', // Dark mode background
},
// ... more styles
})
Initial messages are defined in the initialMessages array. You can modify or add more messages:
const initialMessages: IMessage[] = [
{
_id: 1,
text: 'Your message here',
createdAt: new Date(),
user: {
_id: 2,
name: 'Bot Name',
},
},
// ... more messages
]
The current user is defined in the user object:
const user = useMemo(() => ({
_id: 1,
name: 'Developer',
}), [])
This example works on:
If image picker or location features don't work:
If dependencies fail to install in Expo Snack:
Maps may not work on web or some simulators:
The ExpoSnack.tsx file is organized into these sections:
Once you have this working, you can:
When using in Expo Snack:
For production apps, it's recommended to use this as a starting point and develop locally with Expo CLI or React Native CLI.
This example is based on the React Native Gifted Chat library which is MIT licensed.
Happy chatting! 🎉