Skip to content
This repository has been archived by the owner on Apr 2, 2018. It is now read-only.

if define a Component has componentDidUpdate, the 'why-did-you-update' will not work.. #19

Open
mofelee opened this issue May 17, 2016 · 2 comments

Comments

@mofelee
Copy link

mofelee commented May 17, 2016

componentDidUpdate will override the original method, can we use createChainedFunction to link those function?

https://github.com/garbles/why-did-you-update/blob/master/src/index.js#L27

componentWillUpdate's SpecPolicy:
https://github.com/facebook/react/blob/master/src%2Fisomorphic%2Fclassic%2Fclass%2FReactClass.js#L242-258

how mixin work with SpecPolicy.DEFINE_MANY
https://github.com/facebook/react/blob/master/src%2Fisomorphic%2Fclassic%2Fclass%2FReactClass.js#L517-L519

createChainedFunction:
https://github.com/facebook/react/blob/master/src%2Fisomorphic%2Fclassic%2Fclass%2FReactClass.js#L621-L634

@mofelee mofelee changed the title componentDidUpdate will override the original method, can we use createChainedFunction to link those function? if define a Component has componentDidUpdate, the 'why-did-you-update' will not work.. May 17, 2016
@garbles
Copy link
Owner

garbles commented May 17, 2016

Definitely aware of this. Thanks for making an issue.

@mofelee
Copy link
Author

mofelee commented May 18, 2016

we can inject code after instantiate (wrap mountComponent function and replace this._instance.componentDidUpdate when called mountComponent )
https://github.com/facebook/react/blob/master/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js#L255

https://github.com/facebook/react/blob/master/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js#L964

https://github.com/facebook/react/blob/master/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js#L1012

but I don't know how to wrap ReactCompositeComponent 😓😓

import ReactCompositeComponent from 'react/lib/ReactCompositeComponent';
const _mountComponent = ReactCompositeComponent.Mixin.mountComponent;
ReactCompositeComponent.Mixin =  {abc: 111}; // it will throw some error , but doesn't work..

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants