fengyuanchen / compressorjs

JavaScript image compressor.
https://fengyuanchen.github.io/compressorjs/
MIT License
5.23k stars 439 forks source link

how to setstate for the success result #189

Closed Laxman980 closed 2 months ago

Laxman980 commented 3 months ago
new Compressor(file, {
    quality: 0.6,

    // The compression process is asynchronous,
    // which means you have to access the `result` in the `success` hook function.
    success(result) {
        // in this place how we define the setstate. i did setimagedata(result), it show error
    },
});

please would you explain me. i am new here

fengyuanchen commented 2 months ago

Try console.log(result) in the success hook to see what the result is.