-
Notifications
You must be signed in to change notification settings - Fork 271
feat: callback hooks for Reactified components #131
Conversation
Add a second argument to the exported `reactify` method to allow wrapped component to pass in callback hooks for React lifecycle methods. This PR only exposes the willUnmount hook. Other hooks can be added in the future.
Codecov Report
@@ Coverage Diff @@
## master #131 +/- ##
==========================================
- Coverage 100% 99.89% -0.11%
==========================================
Files 77 77
Lines 986 988 +2
Branches 237 238 +1
==========================================
+ Hits 986 987 +1
- Partials 0 1 +1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #131 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 77 77
Lines 986 988 +2
Branches 237 238 +1
=====================================
+ Hits 986 988 +2
Continue to review full report at Codecov.
|
@@ -17,6 +17,11 @@ export type ReactifyProps = { | |||
className?: string; | |||
}; | |||
|
|||
// TODO: add more React lifecycle callbacks as needed | |||
export type LifeCycleCallbacks = { | |||
willUnmount?: () => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small point -- but I think that these should mirror the actual lifecycle names because
- devs are already familiar with them
- some of them start with
componentXXX
and some don't (e.g.,shouldComponentUpdate
). The one's that don't are a little more cryptic when truncated (e.g.componentUpdate
?), so if/when we add more we'll then have a mix of full names and short names which is more complicated than need be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Let me rename this to componentWillUnmount
and I'll adjust the usage in nvd3
charts in superset-ui-plugins
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one comment!
🏆 Enhancements
Add a second argument to the exported
reactify
method to allow wrapped component to pass in callback hooks for React lifecycle methods. This PR only exposes the willUnmount hook. Other hooks can be added in the future.