diff --git a/src/hoc/withModalLifecycle.js b/src/hoc/withModalLifecycle.js deleted file mode 100644 index a0531396..00000000 --- a/src/hoc/withModalLifecycle.js +++ /dev/null @@ -1,63 +0,0 @@ -import React from 'react'; - -import { ModalContext } from '../context/ModalContext'; -import { ModalEventKeys } from '../constants/Enums'; - - -const eventKeys = Object.keys(ModalEventKeys); - -export function withModalLifecycle(WrappedComponent){ - return class extends React.PureComponent { - static contextType = ModalContext; - - componentDidMount(){ - const modalContext = this.context; - const modalEmitter = modalContext.getEmitterRef(); - - for (const eventKey of eventKeys) { - const functionName = `handle-${eventKey}`; - - this[functionName] = (event) => { - this.childRef?.onModalShow?.(event); - }; - - modalEmitter.addListener(eventKey, this[functionName]); - }; - }; - - componentWillUnmount(){ - const modalContext = this.context; - const modalEmitter = modalContext.getEmitterRef(); - - for (const eventKey of eventKeys) { - const functionName = `handle-${eventKey}`; - modalEmitter.removeListener(eventKey, this[functionName]); - }; - }; - - _handleChildRef = (node) => { - const { ref } = this.props; - - // store a copy of the child comp ref - this.childRef = node; - - if (typeof ref === 'function') { - ref(node); - - } else if (ref) { - ref.current = node; - }; - }; - - render(){ - const props = this.props; - - return ( - - ); - }; - }; -}; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 77a26b52..1ebaa4c5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,6 @@ export * from './module/ModalViewModule'; export * from './constants/Enums'; export * from './context/ModalContext'; -export * from './hoc/withModalLifecycle'; export * from './native_components/RNIModalView'; export * from './native_modules/RNIModalViewModule';