react-selectize
Version:
A Stateless & Flexible Select component for React inspired by Selectize
28 lines (22 loc) • 519 B
JavaScript
;
exports.__esModule = true;
exports.saveState = saveState;
exports.readState = readState;
var KeyPrefix = '@@History/';
function createKey(key) {
return KeyPrefix + key;
}
function saveState(key, state) {
window.sessionStorage.setItem(createKey(key), JSON.stringify(state));
}
function readState(key) {
var json = window.sessionStorage.getItem(createKey(key));
if (json) {
try {
return JSON.parse(json);
} catch (error) {
// Ignore invalid JSON.
}
}
return null;
}