I have a React.js component and I'd like to define a higher order method like so -
updater: function (path) {
return function (value) {
this.setState(this.modules.setter.set(this.state, path, value))
}
}
Where this.modules.setter.set
returns an updated version of the state, with a new value
lying along the specified path
.
This is in the hopes of being able to define a method like so -
updateUserStreet: this.updater('user.address.street')
I have no problem with creating the desired this.modules.setter.set
, however I'm having trouble using a higher-order method in general.
The console is telling me that this.updater is not a function
Any thoughts?