UNPKG

communication-react-19

Version:

React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)

30 lines 956 B
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import React, { useContext, createContext, useState, useEffect } from 'react'; /** * * @param props * @returns */ export const ACSAudioProvider = (props) => { const { audioContext, children } = props; const [stateAudioContext, setStateAudioContext] = useState(undefined); useEffect(() => { // Create the AudioContext only when the component is rendered setStateAudioContext(audioContext); }, [audioContext]); const alreadyWrapped = useAudio(); if (alreadyWrapped) { return React.createElement(React.Fragment, null, children); } return React.createElement(ACSAudioContext.Provider, { value: stateAudioContext }, props.children); }; /** * @private */ const ACSAudioContext = createContext(undefined); /** * @private */ export const useAudio = () => useContext(ACSAudioContext); //# sourceMappingURL=AudioProvider.js.map