Closed 40818419 closed 5 years ago
Hi! Thanks for the PR.
I'm a little confused by the additional component param. We already have a ref to the component, this.refs.component
, that will allows us access to getValidatorData
.
Can you provide a little more information about the problem you are solving?
hey, this.refs.component
is giving me Constructor
because it's wrapped into connectToStores
, and we need to access SomeComponent
. Is there any possibility to pass the scope?
Ah. Thanks for the clarity. Let me think about the best approach.
I'm assuming that swapping the composition ordering also fails?
export default connectToStores(validation(strategy)(SomeComponent))
yes, those methods are required:
static getStores() {
return [...]
}
static getPropsFromStores() {
return {
...
}
}
Thanx!
@40818419 I'd recommend using this approach to define your static methods on the finalized HOC rather than trying to access them on the wrapped component.
@40818419 I agree with @idolize here. Wrapping your component in another HOC on export that simply adds the statics to the outer component is the recommended solution.
If you need code samples for this, I can help too.
I would like to merge in your .eslintrc changes. Can you update this PR with just those?
@jurassix Actually, in the example linked, the statics
decorator does not create another HOC (just simply adds the static methods to the existing HOC), but either way works :smile:
@idolize Yeah adding directly to outer component does seems better. I've done some perf tests on HOC in the past and the deeper you go the more processing time is required each render.
@jurassix how this will look like than? will update PR.
@40818419 Try this:
const component = validation(strategy)(connectToStores(SomeComponent))
component.getStores() {
return [...]
}
component.getPropsFromStores() {
return {
...
}
}
export default component;
@40818419 Or this: just depends on your syntax preference
const component = validation(strategy)(connectToStores(SomeComponent))
Object.assign(component, {
getStores() {
return [...]
},
getPropsFromStores() {
return {
...
}
}
});
export default component;
@40818419 did this work for you?
@jurassix unfortunately not, need more time...
closing due to inactivity.
…handleValidation. Added linting params.
Example of Alt + Flux (http://alt.js.org) + React Bootstrap: