Last active
May 12, 2019 15:44
-
-
Save mohandere/e8491f8193b104c153833083fbcce0a3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import hoistNonReactStatic from 'hoist-non-react-statics'; | |
const withSearch = (WrappedComponent) => { | |
class WithSearch extends React.Component {/*...*/} | |
hoistNonReactStatic(EithSearch, WrappedComponent); | |
return WithSearch; | |
} | |
// Define a static method | |
ProductsList.staticMethod = function() {/*...*/} | |
// Now apply a HOC | |
const ProductsListWithSearch = withSearch(ProductsList); | |
// The enhanced component has no static method | |
typeof ProductsListWithSearch.staticMethod === 'function' // true |
This file contains hidden or 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
// Define a static method | |
ProductsList.staticMethod = function() {/*...*/} | |
// Now apply a HOC | |
const ProductsListWithSearch = withSearch(ProductsList); | |
// The enhanced component has no static method | |
typeof ProductsListWithSearch.staticMethod === 'undefined' // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment