The only way I know to inject props into a component is through a parent component like so
render() {
return <Child ...this.someProps />
}
How do I inject more props to the Child
component dynamically through a function like so
inject(someProps, Child)
Similar to how redux-react connect(mapStateToProps, mapDispatchToProps)(Child)
works
Higher-order Components is what you are looking for: https://gist.github.com/sebmarkbage/ef0bf1f338a7182b6775
At the end of the day you'll be wrapping your component with a parent one (connect
is in fact a component).
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