The .setItem() local storage function returns undefined. You need to perform the local storage update and then return the new state object:
switchoff: function(){
localStorage.setItem('state', 'off');
this.setState({lights: 'off'});
},
The .setItem() local storage function returns undefined. You need to perform the local storage update and then return the new state object:
switchoff: function(){
localStorage.setItem('state', 'off');
this.setState({lights: 'off'});
},