VerticalLinearStepper.js
handleNext = (e, storageType) => {
console.log("handleNext--->");
if (!storageType) return; // do nothing if no value to work with
if (storageType === "local") {
console.log("window ---> local");
// another tab asked for the sessionStorage -> send it
localStorage.setItem(
"sessionStorage",
JSON.stringify({ sessionStorage })
);
// the other tab should now have it, so we're done with it.
//localStorage.removeItem("sessionStorage"); // <- could do short timeout as well.
} else if (storageType === "session") {
console.log("window ---> session");
// another tab sent data <- get it
sessionStorage.setItem("step1Completed", "step1Completed");
var data = JSON.parse(storageType);
for (var key in data) {
sessionStorage.setItem(key, data[key]);
}
}
console.log("localStorage", localStorage.getItem("sessionStorage"));
console.log("session storage", sessionStorage.getItem("step1Completed"));
//listen for changes to localStorage
if (window.addEventListener) {
console.log("window --->");
window.addEventListener("storage", "xxx", false);
} else {
console.log("window --->");
window.attachEvent("onstorage", "xxx");
}
// Ask other tabs for session storage (this is ONLY to trigger event)
if (!sessionStorage.length) {
localStorage.setItem("getSessionStorage", "foobar");
localStorage.removeItem("getSessionStorage", "foobar");
}
if (this.canGoForward()) {
this.setState(prevState => ({ activeStep: prevState.activeStep + 1 }));
}
};
pageOne.js
<!-- language-all: lang-or-tag-here -->
completedState = (e, storageType) => {
console.log("localStorage", localStorage.getItem("sessionStorage"));
console.log("session storage", sessionStorage.getItem("step1Completed"));
};