UNPKG

react-global-storage

Version:
35 lines (29 loc) 595 B
/** * Global Storage for React v0.0.5 * KosiakMD * Anton Kosiak * kosiakMD@yandex.ua */ 'use strict'; 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;