Explorar el Código

@uppy/url: refactor `UrlUI` (#4143)

Antoine du Hamel hace 2 años
padre
commit
5c2bdf28ac
Se han modificado 1 ficheros con 5 adiciones y 11 borrados
  1. 5 11
      packages/@uppy/url/src/UrlUI.jsx

+ 5 - 11
packages/@uppy/url/src/UrlUI.jsx

@@ -1,23 +1,17 @@
 import { h, Component } from 'preact'
 
 class UrlUI extends Component {
-  constructor (props) {
-    super(props)
-    this.handleKeyPress = this.handleKeyPress.bind(this)
-    this.handleClick = this.handleClick.bind(this)
-  }
-
   componentDidMount () {
     this.input.value = ''
   }
 
-  handleKeyPress (ev) {
+  #handleKeyPress = (ev) => {
     if (ev.keyCode === 13) {
-      this.handleSubmit()
+      this.#handleSubmit()
     }
   }
 
-  handleSubmit () {
+  #handleSubmit = () => {
     const { addFile } = this.props
     const preparedValue = this.input.value.trim()
     addFile(preparedValue)
@@ -32,14 +26,14 @@ class UrlUI extends Component {
           type="text"
           aria-label={i18n('enterUrlToImport')}
           placeholder={i18n('enterUrlToImport')}
-          onKeyUp={this.handleKeyPress}
+          onKeyUp={this.#handleKeyPress}
           ref={(input) => { this.input = input }}
           data-uppy-super-focusable
         />
         <button
           className="uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Url-importButton"
           type="button"
-          onClick={this.handleSubmit}
+          onClick={this.#handleSubmit}
         >
           {i18n('import')}
         </button>