-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(innercomponent): Manage inner component changing size detection
This new feature allow to watch inner component changing (new state, props) and notice the SizeFetcher
- Loading branch information
Luc Merceron
committed
Apr 30, 2017
1 parent
cfc62fe
commit e14af63
Showing
3 changed files
with
83 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react' | ||
|
||
const getDisplayName = wrappedComponent => wrappedComponent.displayName || wrappedComponent.name | ||
|
||
const EnhanceInnerComponent = InnerComponent => { | ||
// const component = InnerComponent | ||
|
||
// const NewInnerComponent = class extends React.Component { | ||
// render() { | ||
// return component(this.props) | ||
// } | ||
// } | ||
// NewInnerComponent.displayName = getDisplayName(component) | ||
|
||
class EnhancerInnerComponent extends InnerComponent { | ||
componentDidMount() { | ||
if (super.componentDidMount) super.componentDidMount() | ||
} | ||
componentDidUpdate() { | ||
if (super.componentDidUpdate) super.componentDidUpdate() | ||
|
||
this.props.sizeMayChange() | ||
} | ||
render() { | ||
return super.render() | ||
} | ||
} | ||
|
||
EnhancerInnerComponent.displayName = `EnhancerInner(${getDisplayName(InnerComponent)})` | ||
|
||
return EnhancerInnerComponent | ||
} | ||
|
||
export default EnhanceInnerComponent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters