### Render React Native View on External Display (JavaScript) Source: https://github.com/mybigday/react-native-external-display/blob/master/README.md This snippet demonstrates how to use the `react-native-external-display` library to render a React Native view on an external screen. It utilizes the `useExternalDisplay` hook to get available screens and the `ExternalDisplay` component to wrap the content to be displayed. The `fallbackInMainScreen` prop ensures content is shown on the main screen if no external display is detected. The `Video` component from `react-native-video` is used as an example content. ```javascript import React from 'react' import Video from 'react-native-video' import ExternalDisplay, { useExternalDisplay, } from 'react-native-external-display' function App() { const screens = useExternalDisplay() return ( ) } ``` -------------------------------- ### Render View on External Display with React Native Source: https://github.com/mybigday/react-native-external-display/blob/master/packages/react-native-external-display/README.md This example demonstrates how to use the `ExternalDisplay` component and the `useExternalDisplay` hook to render a React Native view on an external display. It takes a `screen` prop to specify the target display and can fallback to the main screen if no external display is found. Dependencies include React and react-native-external-display. ```javascript import React from 'react' import ExternalDisplay, { useExternalDisplay } from 'react-native-external-display' function App() { const screens = useExternalDisplay() return ( External Display ) } ``` -------------------------------- ### Render Multiple Contents on External Displays in React Native Source: https://context7.com/mybigday/react-native-external-display/llms.txt This snippet demonstrates how to use the `react-native-external-display` library to render distinct content on each connected external display. It utilizes the `useExternalDisplay` hook to detect available screens and the `ExternalDisplay` component to map content to specific screens. The example shows dynamic content based on screen ID and a live counter. ```jsx import React, { useState } from 'react'; import { View, Text, ScrollView } from 'react-native'; import ExternalDisplay, { useExternalDisplay } from 'react-native-external-display'; function MultiDisplayApp() { const screens = useExternalDisplay(); const [counter, setCounter] = useState(0); React.useEffect(() => { const timer = setInterval(() => setCounter(c => c + 1), 1000); return () => clearInterval(timer); }, []); return ( {Object.entries(screens).map(([screenId, screen]) => ( Display: {screenId} {counter}s Resolution: {screen.width} x {screen.height} ))} Main Screen - {Object.keys(screens).length} external display(s) ); } ``` -------------------------------- ### Get Current Screen Information (React Native Function) Source: https://context7.com/mybigday/react-native-external-display/llms.txt The getScreens function synchronously retrieves information about currently connected external displays. It returns an object where keys are screen IDs and values contain screen dimensions and mirroring status. This is useful for immediate checks without setting up listeners. ```javascript import { getScreens } from 'react-native-external-display'; import { Button, Alert } from 'react-native'; function ScreenInfoButton() { const handlePress = () => { const screens = getScreens(); // Returns: { [screenId: string]: { id: string, width: number, height: number, mirrored?: boolean } } if (Object.keys(screens).length === 0) { Alert.alert('No External Screens', 'No external displays detected'); } else { Object.entries(screens).forEach(([id, screen]) => { console.log(`Screen ${id}:`, screen.width, 'x', screen.height); }); Alert.alert('Screens Found', `${Object.keys(screens).length} external display(s) connected`); } }; return