Parcourir la source

@uppy/react: remove `Wrapper.ts` (#5032)

Antoine du Hamel il y a 1 an
Parent
commit
619f8ae4e8
1 fichiers modifiés avec 0 ajouts et 59 suppressions
  1. 0 59
      packages/@uppy/react/src/Wrapper.ts

+ 0 - 59
packages/@uppy/react/src/Wrapper.ts

@@ -1,59 +0,0 @@
-import { createElement as h, Component } from 'react'
-import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
-import type { UIPlugin, Uppy } from '@uppy/core'
-import PropTypes from 'prop-types'
-import { uppy as uppyPropType } from './propTypes.ts'
-
-interface UppyWrapperProps<M extends Meta, B extends Body> {
-  uppy: Uppy<M, B>
-  plugin: string
-}
-
-class UppyWrapper<M extends Meta, B extends Body> extends Component<
-  UppyWrapperProps<M, B>
-> {
-  static propTypes = {
-    uppy: uppyPropType.isRequired,
-    plugin: PropTypes.string.isRequired,
-  }
-
-  private container: HTMLDivElement
-
-  componentDidMount(): void {
-    this.installPlugin()
-  }
-
-  componentDidUpdate(prevProps: UppyWrapperProps<M, B>): void {
-    const { uppy } = this.props
-    if (prevProps.uppy !== uppy) {
-      this.uninstallPlugin(prevProps)
-      this.installPlugin()
-    }
-  }
-
-  componentWillUnmount(): void {
-    this.uninstallPlugin()
-  }
-
-  private refContainer = (container: UppyWrapper<M, B>['container']) => {
-    this.container = container
-  }
-
-  installPlugin(): void {
-    const { plugin, uppy } = this.props
-    const pluginObj = uppy.getPlugin(plugin) as UIPlugin<any, M, B>
-
-    pluginObj.mount(this.container, pluginObj)
-  }
-
-  uninstallPlugin({ uppy } = this.props): void {
-    const { plugin } = this.props
-    ;(uppy.getPlugin(plugin) as UIPlugin<any, M, B>).unmount()
-  }
-
-  render(): ReturnType<typeof h> {
-    return h('div', { className: 'uppy-Container', ref: this.refContainer })
-  }
-}
-
-export default UppyWrapper