react-sip icon indicating copy to clipboard operation
react-sip copied to clipboard

Silly question contexts

Open mattronix opened this issue 5 years ago • 2 comments

Hello :)

Sorry for a possibly silly question but i am unable to use the contexts when i try to access {sip.status} I get Line 53: 'sip' is not defined no-undef

and if i import sip also does not work, what silly thing am I doing wrong and thanks for the help! :)

(Registration and everything else works)

mattronix avatar Dec 21 '19 17:12 mattronix

@mattronix i am having bit of issue accessing context can you please share sample of your code how did you do that, that would be awesome. I didn't find any sample code regarding that in readme

asifmi2 avatar May 03 '20 16:05 asifmi2

This library uses React legacy context.

My child component :

import { sipPropType, callPropType } from '@evercall/react-sip';

const SipPhone = (props, context) => {

  const Sip = context;

  const handleCall = () => {
    console.log('handleCall', '\n' , Sip)
  }

  return (
    <div>
      <Button onClick={handleCall}>Call</Button>
    </div>
  );
}

SipPhone.contextTypes = {
  sip: sipPropType,
  call: callPropType,
  
  registerSip: PropTypes.func,
  unregisterSip: PropTypes.func,
  
  answerCall: PropTypes.func,
  startCall: PropTypes.func,
  stopCall: PropTypes.func,
}

export default SipPhone;

Parent component :


import { SipProvider } from '@evercall/react-sip';
<SipProvider {...SETTINGS from Readme} >
    <SipPhone/>
</SipProvider>

toderitagcristian avatar Apr 06 '21 09:04 toderitagcristian