I am using Vite to build an SPA with React (typescript), and I am trying to register a service-worker. I am registering the script as type module, and service-worker.ts sits at src/web-worker/service-worker.ts. There is also a tsconfig.json at src/web-worker Everything works in Dev, but when it’s built,…
Category: Questions
Getting compilation errors regarding loaders when running React app
Hi I’m having an issue when trying to run my react app. I’ve installed a couple of packages to from a tutorial using the ceramic and 3id networks. This error has only shown up recently and I’ve looked online but still not too sure what be causing the issue. The version of node I am using is …
How to get all values in a data table
I am trying to get all the values in a JavaScript data table but whenever I try it says, “table.length is not a function” or, “table.size is not a function” (I’ve tried both). Here is the code I want to use: I want it to return an integer value to the console. How would I do this…
Trying to position JavaScript variables
I’m just learning javascript and I’m trying to center the theDate var by using the style tag but it stays to the far left anyone see where I’m going wrong? Answer your css is centering the element with the id theDate, so wrap that string in a with that id document.write(‘<div id=…
Can’t stop an infinite loop at nested component at useEffect hook
I am trying to curb useEffect related to nested components. Here are the components: Parent (it receives data from API): const ListOfLots = (props) => { const initial = {listLots: props.lots, …
Migrating from Babel to SWC with React
TL;DR How to translate a node script like this: to use SWC instead of Babel? Context We recently upgraded our Next.js version. Next.js now supports SWC instead of Babel. The unit tests for React in our project are written with RITEway. The test command is: It transforms the files with Babel first because othe…
innerHTML returns undefined – JavaScript
I’m creating a game on the web for my studies. I need to create a card game where each card has its own data (number and power name), data is taken from data.txt and put in an array that is then randomized. data.txt looks something like this: Play() function scrambles the deck when the PLAY button is pr…
Divergence with lookahead RegExp
I’m doing a test where all links that don’t have ‘investing’ and ‘news’ are rejected, but I’m not understanding the logic of ?= and ?!, and I believe I’m doing something wrong since the opposite of the logic below is not being matched. Could someone give me a li…
How do I add a color filter to an image so that its average RGB gets closer to that color?
I have a 100×100 image: I get all of its pixels and I calculate the average RGB of that image: I also have a reference RGB of a different color: I know now want to add a filter to the image, so that the avgRgbOfImg gets pretty close to my refRgb: In simpler terms, I have an image and I
HTML video player sound cuts out after through skimming video
I’m currently having issues with a dynamically loaded html video player on my site, where I set the source of a HTML video player using JS by clicking on a button. The problem is, once the video is playing it runs fine, but as soon as I skim the video or jump ahead, doesn’t matter how far, the sou…