alewin/useWorker

_toConsumableArray2 ReferenceError in simple codesandbox example

marco-m-alves opened this issue · 3 comments

Hi there, I'm problem making a very basic mistake in trying to get useWorker to work. Any hints/pointers would be very helpful. Thank you.

Context:
I'm trying to use useWorker to parse large CSV files. Unfortunately, I've so far been unable to put a small example to work.

Problem:
The code sandbox example below gives the following error: ReferenceError: Can't find variable: _toConsumableArray2

Code:
https://codesandbox.io/s/hungry-einstein-4gsel?file=/src/App.js

import React, { useState } from "react";
import { useWorker } from "@koale/useworker";
import "./styles.css";

const processArray = () => {
  const items = [...Array(1000).map((item, offset) => offset)];
  return items.sort();
};

export default function App() {
  const [data, setData] = useState("ready to start");
  const [processWorker] = useWorker(processArray);

  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
      <button
        onClick={_ => {
          setData("started");
          processWorker().then(_ => setData("finished"));
        }}
      >
        Start
      </button>
      <p>{data}</p>
    </div>
  );
}

Hi @marco-m-alves, I don't understand why, but it seems to be a sandbox problem.
I ran the project locally and it works!

Here a demo

The demo does not work on Safari Version 13.1.1 (15609.2.9.1.2) — although it works on Chrome Version 83.0.4103.116 (Official Build) (64-bit)

On Safari it get the following errors — see screenshots:

  1. First time I press start
  2. Second time I press start

Screenshot 2020-07-12 at 13 11 58
Screenshot 2020-07-12 at 13 12 28

Thanks @marco-m-alves for reporting the Safari bug, now it should be fixed in 3.2.1 🚀

https://github.com/alewin/useWorker/releases/tag/3.2.1