Skip to content

Commit

Permalink
Store payloads in localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonEtco committed Jan 30, 2018
1 parent a1bbe43 commit 6193929
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"jsx-quotes": 0
},
"env": {
"jest": true
"jest": true,
"browser": true
}
}
5 changes: 4 additions & 1 deletion src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ function compare (a, b) {
export default class App extends Component {
constructor (props) {
super(props)
this.state = { log: [], filter: '', connection: false }
const ref = localStorage.getItem('smee:log')
this.state = { log: ref ? JSON.parse(ref) : [], filter: '', connection: false }
}

componentDidMount () {
Expand Down Expand Up @@ -59,6 +60,8 @@ export default class App extends Component {
if (this.state.log.findIndex(l => l[idProp] === json[idProp]) === -1) {
this.setState({
log: [...this.state.log, json]
}, () => {
localStorage.setItem('smee:log', JSON.stringify(this.state.log))
})
}
}
Expand Down

0 comments on commit 6193929

Please sign in to comment.