react-native-google-cast
Version:
React Native wrapper for the Google Cast SDK for iOS and Android
20 lines (14 loc) • 451 B
text/typescript
import { useEffect, useState } from 'react'
import CastState from '../types/CastState'
import CastContext from './CastContext'
export default function useCastState() {
const [castState, setCastState] = useState<CastState | null>()
useEffect(() => {
CastContext.getCastState().then(setCastState)
const changed = CastContext.onCastStateChanged(setCastState)
return () => {
changed.remove()
}
}, [])
return castState
}