Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
using web-worker in react

// here is my web-worker code

import * as d3 from 'd3';
// import d3 from 'https://d3js.org/d3-collection.v1.min.js';
// importScripts('d3');
//fibo.worker.js
// eslint-disable-next-line import/no-anonymous-default-export
export default () => {
  // eslint-disable-next-line no-restricted-globals
  self.onmessage = (message) => {
    const { nodes, links, width, height } = message.data;
    const simulation = d3
      .forceSimulation(nodes)
      .force(
        'link',
        d3
          .forceLink(links) // This force provides links between nodes
          .id((d) => d.id) // This sets the node id accessor to the specified function. If not specified, will default to the index of a node.
          .distance(10)
      )
      .force('charge', d3.forceManyBody().strength(-500)) // This adds repulsion (if it's negative) between nodes.
      .force('center', d3.forceCenter(width / 3, height / 3))

      .force(
        'collision',
        d3.forceCollide().radius((d) => d.radius)
      );

    postMessage(simulation);
  };
};
I'm getting an error

Uncaught ReferenceError: d3__WEBPACK_IMPORTED_MODULE_0__ is not defined at self.onmessage

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

cause by: import * as d3 from 'd3'; remove this and use @ts-ignore

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!