I'm trying to store functions in localStorage
class Data extends Component {
constructor(props);
var func = {
f1 : this.f1.bind(this),
f2 : this.f1.bind(this)
}
localStorage.setItem("method",func);
f1(var id){
console.log("F1" : id);
}
f2(var id){
console.log("F2" : id);
}
}
class App extends Component{
constructor(props){
super(props);
var m = localStorage.getItem("method");
m.f1(1);
m.f2(3);
}
I get error "m.f1" is not a function. Is it possible to fix that, or is what i'm trying to do impossible ? I want to do it to separate function and component for clarity (to avoid having too long code, and because i use the same function in different components), but it's not necessary