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

227
Views
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
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!