Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
cambiar bandera retener número nacional - reaccionar entrada de número de teléfono

¿Cómo conservo el número nacional cuando el usuario cambia de bandera? Si cambian de bandera se deben dejar los números que pusieron anteriormente. setValue no activa el campo de valor.

 function App() { const { register, handleSubmit, watch, errors, setValue, control } = useForm(); const [valueX, setValueX] = useState(""); useEffect(() => { try{ sessionStorage.setItem("national", parsePhoneNumber(valueX).nationalNumber) }catch(err){} try{ sessionStorage.setItem("countryCode", parsePhoneNumber(valueX).countryCallingCode) }catch(err){} }, [valueX]); function test(x){ console.log("changed country") console.log(getCountryCallingCode(x)) setValue("test",x+sessionStorage.getItem("national")) } return ( <div className="App"> <form> <PhoneInput name="test" international value={valueX} onChange={e => setValueX(e)} onCountryChange={e => {test(e)}} control={control} /> </form> </div> ); } export default App;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Bueno, básicamente funciona ahora. Se eliminó el valor en Phoneinput... y se movió setValue a mi useEffect. También parte importante fue tener internacional, provocó algunos problemas con la entrada.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!