Преглед на файлове

yo-yo --> preact rendering in Plugin.js

Artur Paikin преди 7 години
родител
ревизия
126027a9ce
променени са 1 файла, в които са добавени 5 реда и са изтрити 8 реда
  1. 5 8
      src/core/Plugin.js

+ 5 - 8
src/core/Plugin.js

@@ -1,5 +1,4 @@
-const yo = require('yo-yo')
-const nanoraf = require('nanoraf')
+const preact = require('preact')
 const { findDOMElement } = require('../core/Utils')
 const { findDOMElement } = require('../core/Utils')
 const getFormData = require('get-form-data')
 const getFormData = require('get-form-data')
 
 
@@ -63,10 +62,9 @@ module.exports = class Plugin {
     const targetElement = findDOMElement(target)
     const targetElement = findDOMElement(target)
 
 
     if (targetElement) {
     if (targetElement) {
-      // Set up nanoraf.
-      this.updateUI = nanoraf((state) => {
-        this.el = yo.update(this.el, this.render(state))
-      })
+      this.updateUI = (state) => {
+        this.el = preact.render(this.render(state), targetElement, this.el)
+      }
 
 
       this.uppy.log(`Installing ${callerPluginName} to a DOM element`)
       this.uppy.log(`Installing ${callerPluginName} to a DOM element`)
 
 
@@ -81,8 +79,7 @@ module.exports = class Plugin {
         targetElement.innerHTML = ''
         targetElement.innerHTML = ''
       }
       }
 
 
-      this.el = plugin.render(this.uppy.state)
-      targetElement.appendChild(this.el)
+      this.el = preact.render(this.render(this.uppy.state), targetElement)
 
 
       return this.el
       return this.el
     }
     }