I am trying to make a video chat app. I want the answer button to be activated when a call comes in. But I am getting this error:
My Notification.jsx file looks like this:
import React, { useContext } from 'react';
import { Button } from '@mui/material';
import { SocketContext } from '../SocketContext';
const Notification = () => {
const { answerCall, call, callAccepted, isReceivedCall } = useContext(SocketContext);
return (
<>
{call.isReceivedCall && !callAccepted && (
<div style={{ display: 'flex', justifyContent: 'space-around' }}>
<h1>{call.name} is calling:</h1>
<Button variant="contained" color="primary" onClick={answerCall}>
Answer
</Button>
</div>
)}
Notification
</>
)
}
export default Notification
This is how I defined isReceivedCall in SocketContext:
socket.on('calluser', ({ from, name: callerName, signal }) => {
setCall({ isReceivedCall: true, from, name: callerName, signal })
});
}, []);