0

I was wondering how would I export this variable called dialCall to a different page. I'm also not sure how to call it from my app.js

Thanks!

import {Linking,Platform,TouchableOpacity,Text} from "react-native";
export default class MakeCall extends Component {

dialCall = (number) => {
 let phoneNumber = '';
 if (Platform.OS === 'android') { phoneNumber = `tel:${number}`; }
 else {phoneNumber = `telprompt:${number}`; }
 Linking.openURL(phoneNumber);
};

//  Render(){
//         return(
//                 <TouchableOpacity
//                    style={{
//                    height: 30,
//                    width: 30,
//                    backgroundColor: "#329df4",
//                    alignItems: "center",
//                    justifyContent: "center",
//                    borderRadius: 5
//                    }}
//                  onPress={()=>{this.dialCall(123456789)}}
//                 >
//                 <Text>Phone</Text>
//                 </TouchableOpacity>
//               )
//   }

}
export {dialCall} ;

1 Answer 1

1

Have a try with the below code.

import {Linking,Platform} from "react-native";

export const dialCall = (number) => {
 let phoneNumber = '';
 if (Platform.OS === 'android') { phoneNumber = `tel:${number}`; }
 else {phoneNumber = `telprompt:${number}`; }
 Linking.openURL(phoneNumber);
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.