Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

80
Vistas
Problem with the getItem localstorage inputs in form

1

I have a problem with the getItem of my localStorage in my React Form. I put a onChange attribute:

I found the setItem function to store the data in. Here is the function:
 function save_data(){

  let textarea =  
document.querySelectorAll("textarea")
  let input = 
document.querySelectorAll("input[type='text']")
  let saved_fields = []
                                                          
textarea.forEach(x => {

 saved_fields.push({
 key: x.className,
 value: x.value
 })
                                  
})
                          
 input.forEach(x => {
 saved_fields.push({
 key: x.className,
 value: x.value
 })
                                
})
                              
 localStorage.setItem("saved_data", 
 JSON.stringify(saved_fields))

 }

My main problem is that I don't find a way to put the data back to the page after the page reload. I just found out how to persist all my inputs in the console:

window.onload = dataLoad();
                            
function dataLoad () {

 let show_saved_data = 

localStorage.getItem("saved_data");

  console.log('show_saved_data:',JSON.parse(show_saved_data));

   }

Can you guys help me find the retrieve/persist data function?

Here is the html of the form, i use props from another component. I don't know if this can change the function i need to use.

<InputFields 
   stateKey = 'contactInfo' 
   key = {props.contactInfo.id}
   completedFields = 
{props.contactInfo}
     templateFields = {props.templates.contactInfo}
 onDataEntry = {props.onDataEntry}
   newField = {props.newField}
 />
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda