mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-19 01:24:18 +00:00
* relocate .vscode
* Switch to transloadit linter
* Update .eslintrc.json
* autofix code
* unlink and install eslint-config-transloadit@1.1.1
* Change 0 to "off"
* Don't change 'use strict'
* Do not vertically align
* disable key-spacing
* add import/no-extraneous-dependencies per package
* add more react/a11y warnings
* Revert "autofix code"
This reverts commit 14c8a8cde8.
* add import/no-extraneous-dependencies per example and main package
* autofix code (2)
* Allow devDependencies in ./bin
* Change import/no-extraneous-dependencies to warn again
* upgrade linter
* Set import/no-extraneous-dependencies to warn
57 lines
1.1 KiB
JavaScript
57 lines
1.1 KiB
JavaScript
const React = require('react')
|
|
const PropTypes = require('prop-types')
|
|
const uppyPropType = require('./propTypes').uppy
|
|
|
|
const h = React.createElement
|
|
|
|
class UppyWrapper extends React.Component {
|
|
constructor (props) {
|
|
super(props)
|
|
|
|
this.refContainer = this.refContainer.bind(this)
|
|
}
|
|
|
|
componentDidMount () {
|
|
this.installPlugin()
|
|
}
|
|
|
|
componentDidUpdate (prevProps) {
|
|
if (prevProps.uppy !== this.props.uppy) {
|
|
this.uninstallPlugin(prevProps)
|
|
this.installPlugin()
|
|
}
|
|
}
|
|
|
|
componentWillUnmount () {
|
|
this.uninstallPlugin()
|
|
}
|
|
|
|
installPlugin () {
|
|
const plugin = this.props.uppy
|
|
.getPlugin(this.props.plugin)
|
|
|
|
plugin.mount(this.container, plugin)
|
|
}
|
|
|
|
uninstallPlugin (props = this.props) {
|
|
const plugin = props.uppy
|
|
.getPlugin(this.props.plugin)
|
|
|
|
plugin.unmount()
|
|
}
|
|
|
|
refContainer (container) {
|
|
this.container = container
|
|
}
|
|
|
|
render () {
|
|
return h('div', { ref: this.refContainer })
|
|
}
|
|
}
|
|
|
|
UppyWrapper.propTypes = {
|
|
uppy: uppyPropType,
|
|
plugin: PropTypes.string.isRequired,
|
|
}
|
|
|
|
module.exports = UppyWrapper
|