Hey i want to update my phone number component when I'm actaually getting the value of the phone number. I'm using next.js
Also the country code overrides the phonenumber value completely
"use client";
import { useState, useEffect } from "react";
import PhoneInput from "react-phone-input-2";
import "react-phone-input-2/lib/style.css";
import { GetSimCardsResult, Sim, SimCard } from "@jonz94/capacitor-sim";
import { Capacitor } from "@capacitor/core";
const simIsAvailable = Capacitor.isPluginAvailable('Sim');
export default function PhoneInputBox() {
const [phone, setPhone] = useState("");
const [country, setCountry] = useState("us");
if (simIsAvailable) {
useEffect(() => {
let hasPermission = true;
Sim.requestPermissions().then((permStatus) => {
hasPermission = permStatus.readSimCard === "granted";
})
if (hasPermission) {
Sim.getSimCards().then(async (result: GetSimCardsResult) => {
const simCard: SimCard = await result.simCards[0];
setPhone(simCard.number);
setCountry(simCard.isoCountryCode)
})
}
}, []);
}
return (
<PhoneInput
value={phone}
onChange={(phone) => setPhone(phone)}
/>
);
}
Hey i want to update my phone number component when I'm actaually getting the value of the phone number. I'm using next.js
Also the country code overrides the phonenumber value completely