Подождите, пока файл не будет загружен с помощьюact-js reactFileDownload?

Давайте будем понимать это только с кодом;

A.prototype = B.prototype;

function B() {console.log("I am B");this.b1= 30;}
    B.prototype.b2 = 40;

    function A() {console.log("I am A");this.a1= 10;}
    A.prototype.a2 = 20;

    A.prototype = B.prototype;

    A.prototype.constructor = A; 

    var a = new A;
    var b = new B;

    console.log(a);//A {a1: 10, b2: 40}
    console.log(b);//B {b1: 30, b2: 40}

    console.log(A.prototype.constructor);//A
    console.log(B.prototype.constructor);//A
    console.log(A.prototype);//A {b2: 40}
    console.log(B.prototype);//A {b2: 40}
    console.log(a.constructor === A); //true
    console.log(b.constructor === A); //true

console.log(a.a2);//undefined

enter image description here [/g0]

A .prototype = Object.create (B.prototype);

function B() {console.log("I am B");this.b1= 30;}
B.prototype.b2 = 40;

function A() {console.log("I am A");this.a1= 10;}
A.prototype.a2 = 20;

A.prototype = Object.create(B.prototype);

A.prototype.constructor = A; 

var a = new A;
var b = new B;

console.log(a);//A {a1: 10, constructor: function, b2: 40}
console.log(b);//B {b1: 30, b2: 40} 

console.log(A.prototype.constructor);//A
console.log(B.prototype.constructor);//B
console.log(A.prototype);//A {constructor: function, b2: 40}
console.log(B.prototype);//B {b2: 40}
console.log(a.constructor === A); //true
console.log(b.constructor === B); //true
console.log(a.a2);//undefined

enter image description here [/g1]

0
задан x y 6 March 2019 в 13:29
поделиться

1 ответ

Попробуйте это -

var fileDownload = require('react-file-download');
var promise = new Promise((resolve, reject) => {
  fileDownload(data, 'filename.csv');
  // wait 2 sec then resolve
  setTimeout(() => { resolve(true) }, 2000);
});

Тогда вы можете сделать -

await promise().then(result => console.log(result)).catch(err => console.log(err.message));
0
ответ дан ra89fi 6 March 2019 в 13:29
поделиться
Другие вопросы по тегам:

Похожие вопросы: