I'm learning about HOC from this article but have not see proc
and method
before. What does those refer to?
function refsHOC(WrappedComponent) {
return class RefsHOC extends React.Component {
proc(wrappedComponentInstance) {
wrappedComponentInstance.method()
}
render() {
const props = Object.assign({}, this.props, {ref: this.proc.bind(this)})
return <WrappedComponent {...this.props}/>
}
}
}
this.proc
refers to the method
proc(wrappedComponentInstance) {
wrappedComponentInstance.method()
}
wrappedComponentInstance.method()
is a just an example of how to call an arbitrary method on the wrapped component. The article says:
In the following example we explore how to access instance methods and the instance itself of the WrappedComponent via refs
So, neither has anything to do with React specifically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With