Skip to content

Commit bc81ad9

Browse files
Better explanation and better variable names
1 parent a8a7d87 commit bc81ad9

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/components/LoadFromStorage.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import React from 'react';
22

3-
class LoadFromStorage extends React.Component {
3+
/**
4+
* This class only really exists to take advantage of the dispatch code so we can trigger
5+
* loading from localStorage.
6+
*/
7+
class LoadFromLocalStorage extends React.Component {
48

59
componentDidMount() {
6-
this.props.radarDispatch && this.props.radarDispatch({type:"loadFromStorage"})
10+
this.props.radarDispatch && this.props.radarDispatch({type:"loadFromLocalStorage"});
711
}
812

913
render() {
1014
return null;
1115
}
1216
}
1317

14-
export default LoadFromStorage;
18+
export default LoadFromLocalStorage;

src/components/RadarProvider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function radarReducer(state, action) {
2727
console.log(state.data)
2828
return { ...state, data: state.data };
2929
}
30-
case "loadFromStorage": {
30+
case "loadFromLocalStorage": {
3131
const storageData = JSON.parse(localStorage.getItem("youData"));
3232
if (storageData && Array.isArray(storageData)) {
3333
return {

src/components/SkillsSelector.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import InputLabel from "@mui/material/InputLabel";
44
import MenuItem from "@mui/material/MenuItem";
55
import Select from "@mui/material/Select";
66
import { RadarConsumer } from "./RadarProvider";
7-
import LoadFromStorage from "./LoadFromStorage";
7+
import LoadFromLocalStorage from "./LoadFromStorage";
88

99
const SkillsSelector = () => {
1010

@@ -18,7 +18,7 @@ const SkillsSelector = () => {
1818
marginBottom: "25px",
1919
}}
2020
>
21-
<LoadFromStorage radarDispatch={dispatch} />
21+
<LoadFromLocalStorage radarDispatch={dispatch} />
2222
<Box sx={{ minWidth: 350 }}>
2323
<FormControl fullWidth>
2424
<InputLabel id="json-selector-label">Skills</InputLabel>

0 commit comments

Comments
 (0)