Skip to content

Commit 2eb1363

Browse files
daveiverson-pearalvaromb
authored andcommitted
added displayName property to the 'listenToKeyboardEvents' HOC in the form of 'KeyboardAware{Component Name}' (example: KeyboardAwareScrollView). Added a helper 'getDisplayName' function to determine the name. (#241)
1 parent 8a49b1c commit 2eb1363

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/KeyboardAwareHOC.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ export type ScrollIntoViewOptions = ?{
6363
) => ScrollPosition
6464
}
6565

66+
function getDisplayName(WrappedComponent: React$Component) {
67+
return WrappedComponent.displayName || WrappedComponent.name || 'Component'
68+
}
69+
6670
function listenToKeyboardEvents(ScrollableComponent: React$Component) {
6771
return class extends React.Component<
6872
KeyboardAwareHOCProps,
@@ -78,6 +82,8 @@ function listenToKeyboardEvents(ScrollableComponent: React$Component) {
7882
handleOnScroll: Function
7983
state: KeyboardAwareHOCState
8084

85+
static displayName = `KeyboardAware${getDisplayName(ScrollableComponent)}`
86+
8187
static propTypes = {
8288
viewIsInsideTabBar: PropTypes.bool,
8389
resetScrollToCoords: PropTypes.shape({

0 commit comments

Comments
 (0)