Skip to content
This repository has been archived by the owner on Nov 13, 2022. It is now read-only.

Silly question contexts #31

Open
mattronix opened this issue Dec 21, 2019 · 2 comments
Open

Silly question contexts #31

mattronix opened this issue Dec 21, 2019 · 2 comments

Comments

@mattronix
Copy link

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)

@asifmi2
Copy link

asifmi2 commented May 3, 2020

@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

@toderitagcristian
Copy link

toderitagcristian commented Apr 6, 2021

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>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants