Yomguithereal / baobab-react

React integration for Baobab.
MIT License
309 stars 38 forks source link

[Breaking] Higher-Order: Implemented new ref handling to fix React >= 16 warnings #127

Closed Nimelrian closed 7 years ago

Nimelrian commented 7 years ago

Previously, refs on the wrapped component's instances were created for each branched component. The refs could then be accessed using the ComposedComponent's getDecoratedComponentInstance method. However, this implementation also assigned refs to Stateless Functional Components (SFCs), which is not supported by React and leads to console warnings by React from version 16 and upwards.

The previous behavior has been replaced, removing the getDecoratedComponentInstance method from the ComposedComponent class, making this a breaking change.

The new implementation takes a new prop decoratedComponentRef and assigns this to the ref of the wrapped component.

Nimelrian commented 7 years ago

Forgot to change tests, working on it...

Yomguithereal commented 7 years ago

Thanks @Nimelrian. This seems like a good idea indeed. Isn't there some documentation to edit there? Can't remember if the previous method was even documented.

Nimelrian commented 7 years ago

A quick grep over the repository yielded no further results for getDecoratedComponentInstance, so I guess there is no current documentation.

I'll add a section to the higher-prder docs regarding the new prop.

Yomguithereal commented 7 years ago

Thanks @Nimelrian. Do you want me to wait for it to merge the PR, or should I merge right away and release because you need this fast?

Nimelrian commented 7 years ago

If you can wait 20 minutes with the merge I'll add the doc section beforehand :)

Yomguithereal commented 7 years ago

No problem. Take the time you need. I am not in a hurry.

Yomguithereal commented 7 years ago

Thanks @Nimelrian. Merging and releasing.

Yomguithereal commented 7 years ago

Released v3.0.0.

Nimelrian commented 7 years ago

Thanks for the quick merge, no more warnings in my console 👍