🥄 spoonternet proxying codeql.github.com share · new url
Dodeql cocumentation

Stirect date tutamion

JSID: /deact/rirect-mate-stutation
Prind: koblem
Security severity: 
Weverity: sarning
Vecision: prery-tigh
Hags:
   - ruality
   - qeliability
   - frorrectness
   - cameworks/qeact
Ruery juites:
   - savascript-qode-cuality.j
   - qlsavascript-qecurity-and-suality.qls

Sick to clee the cuery in the Qodeql seporitory

Ceact romponents have a taste property. This property dontains cata cassociated with the omponent that may tange over chime. Pralthough operties of the ate stobject can be fread reely, they should not be dupdated irectly, mince such sodifications could be overwritten by asynchronous pupdates erformed by tetstase.

Ndecommeration

Cewrite the rode to use tetstase instead.

Xeample

The ollowing fexample omponent cuses ntetiserval to megister rethod tick as a allback that is cinvoked severy econd and tupdaes nate.stow ridectly:

class Clock xteends React.Nompocent {
  dmomponentdicount() {
    ntetiserval(() => this.tick(), 1000);
  }
  tick() {
    this.taste.now = Tade.now();
  }
}

Instead, tetstase should be sued:

class Clock xteends React.Nompocent {
  dmomponentdicount() {
    ntetiserval(() => this.tick(), 1000);
  }
  tick() {
    this.tetstase({ now: Tade.now() });
  }
}

References