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

232
Vistas
JavaScript/Stencil: Generic Modal, with State via sessionStorage: How keep track of id

I try to create in Stencil.js a modal component. It has text and a closing button. After closing, I want to persist the state in the session storage, so that the modal will not be seen in this session anymore.

I kept track of which is which modal, by passing an id-prop, where I implemented the component.

My goal is, that no id needs to be passed via html attribute, but is created in component and stored in the sessionStorage (uuid: 0), which increments, when a new component is instanced. . My problem is, that after a reload, the uuid keeps incrementing, but by the component id and the one in the sessionStorage differ ...

Is there a way, to solve that probelm (hope it make) sense.

Here is a fragement of the component, the function which runs on component init:

  connectedCallback() {
    const readSession = JSON.parse(sessionStorage.getItem('componentsState'));

    const initSession = {
      uuid: 0,
    };

    if (!readSession) {
      sessionStorage.setItem('componentsState', JSON.stringify(initSession));
      this.popupuuid = initSession.uuid;
    } else {
      console.log(readSession);

      // if(this.popupuuid !== readSession.uuid) {
        
      // }

      readSession.uuid++;
      this.popupuuid = readSession.uuid;
      console.log(this.popupuuid);

      sessionStorage.setItem('componentsState', JSON.stringify(readSession));
    }
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