react-global-storage
Version:
Global storage for clear React project
35 lines (29 loc) • 595 B
JavaScript
/**
* Global Storage for React v0.0.5
* KosiakMD
* Anton Kosiak
* kosiakMD@yandex.ua
*/
;
class GlobalStorage{
constructor (){
Object.defineProperty(this, 'state', {
enumerable: false,
configurable: false,
writable: false,
value: {}
});
}
setState(key, value, component){
Object.defineProperty(this.state, key, {
enumerable: false,
configurable: true,
writable: false,
value: value
});
if(component)
try{component.forceUpdate()}catch(er){console.log(er)}
}
}
var globalStorage = new GlobalStorage();
module.exports = globalStorage;