Skip to content

Commit 976d11a

Browse files
author
Edvinas Jurele
committed
Change localStorage to sessionStorage
1 parent 468f3c8 commit 976d11a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/App.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class App extends Component {
4848
};
4949

5050
componentDidMount() {
51-
if (window.localStorage) {
52-
const cache = JSON.parse(window.localStorage.getItem(STORAGE_KEY));
51+
if (window.sessionStorage) {
52+
const cache = JSON.parse(window.sessionStorage.getItem(STORAGE_KEY));
5353
if (cache != null) {
5454
// eslint-disable-next-line react/no-did-mount-set-state
5555
this.setState({
@@ -89,14 +89,14 @@ class App extends Component {
8989
this.setState(this.getInitialState());
9090
};
9191

92-
removeLocalStorage = () => {
93-
if (window.localStorage) window.localStorage.removeItem(STORAGE_KEY);
92+
removeSessionStorage = () => {
93+
if (window.sessionStorage) window.sessionStorage.removeItem(STORAGE_KEY);
9494
};
9595

9696
pushStateToStorage = () => {
97-
this.removeLocalStorage();
98-
if (window.localStorage)
99-
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state));
97+
this.removeSessionStorage();
98+
if (window.sessionStorage)
99+
window.sessionStorage.setItem(STORAGE_KEY, JSON.stringify(this.state));
100100
};
101101

102102
addTicket = ticketData => {
@@ -165,7 +165,7 @@ class App extends Component {
165165
message: 'Bus ištrinti bilietai ir kamuoliukų istorija.',
166166
},
167167
() => {
168-
this.removeLocalStorage();
168+
this.removeSessionStorage();
169169
this.resetState();
170170
}
171171
);

0 commit comments

Comments
 (0)