Skip to content
Snippets Groups Projects
Commit 321f981b authored by Thor-Herman's avatar Thor-Herman
Browse files

Fix sessionStorage bug #10

Fixed bug with JSON syntax error on reloading a page with sessionstorage
parent ca72237c
No related branches found
No related tags found
No related merge requests found
......@@ -35,8 +35,9 @@ class ArtPage extends React.Component<props, state> {
const pageId = this.props.pageId.toString();
const choices = sessionStorage.getItem(pageId); // Previously stored options. Saved as string
if (choices != null) { // We have stored something previously
const choicesObject = JSON.parse(choices); // Convert string to object
sessionStorage.setItem(pageId, {...choicesObject, [label]: choice}); // Update choices
const choicesObject: object = JSON.parse(choices); // Convert string to object
let choicesObjectStringified : string = JSON.stringify({...choicesObject, [label]: choice});
sessionStorage.setItem(pageId, choicesObjectStringified); // Update choices
} else
sessionStorage.setItem(pageId, JSON.stringify({...this.state.options, [label]: choice}));
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment