Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_toConsumableArray2 ReferenceError in simple codesandbox example #63

Open
marco-m-alves opened this issue Jul 12, 2020 · 3 comments
Open
Labels
question Further information is requested

Comments

@marco-m-alves
Copy link

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>
  );
}
@marco-m-alves marco-m-alves added the question Further information is requested label Jul 12, 2020
@alewin
Copy link
Owner

alewin commented Jul 12, 2020

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

@marco-m-alves
Copy link
Author

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

@alewin
Copy link
Owner

alewin commented Jul 12, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants