score:0
Accepted answer
I needed to add this line right above the first line of my worker function
/* eslint-disable-next-line no-restricted-globals */
let mytimer;
/* eslint-disable-next-line no-restricted-globals */
self.onmessage = function(evt) {
clearInterval(mytimer);
if(evt.data.message === 'pause' || evt.data.message === 'stop' || evt.data.message === 'skip'){
postMessage(evt.data.time)
}
if (evt.data.message == "start" || evt.data.message == "break") {
var i = evt.data.time;
mytimer = setInterval(function() {
i--;
postMessage(i);
}, 1000);
}
};
And also have this in my config-overrides.js
config.output.globalObject = 'this';
module.exports = function override(config, env) {
config.module.rules.push({
test: /\.worker\.js$/,
use: { loader: 'worker-loader' },
})
config.output.globalObject = 'this';
return config;
}
Source: stackoverflow.com
Related Query
- React app on Vercel - 404 not found error after adding Web Worker
- 404 Not Found error in preflight OPTIONS when executing a PUT method in CakePHP API with axios in React App
- Apache Error 404 in react app even after adding .htaccess
- 404 Not Found Nginx Error on Deployment of React App Build
- Surge-deployed React app - getting 404 Page Not Found
- Next JS npm start app load 404 page not found error for physical pages
- Visual Studio Code React not showing error even after adding jsconfig
- Keep getting "Proxy error: Could not proxy request" error after adding proxy to react package.json
- React router after adding createBrowserHistory, the app is not working as expected
- Why does my HTTP GET call to a subroute in react app gives a 404 NOT Found instead of HTML?
- Why does my react app go to the custom 404 not found page when the link is clicked?
- File not found error when trying to 'fetch' json in React App
- Better way to handle 404 page not found in a React app
- I am running a react app locally on apache2 server. It gives error URL not found on this server
- Page content is not loading after redirect - React web app
- I am getting such GET ERR_ABORTED 404 error after deploying react app to github
- Error internationalizing a react jhipster app (resource not found :9000/i18n/de.json?_=ec3c1ea9a5a8fd2043ce89c304a07566:1)
- React Router can't configure URLs on localhost and remote. Receiving 404 not found error
- Font on React app not found when deployed on azure web app
- HTTP Error 404.3 - Not Found - backend .net core, frontend react hosted on azure app service
- Impossible to debug error while packaging Electron React app after adding Redux but works perfectly in developement
- react app 404 error after clear cache in browser
- React Router BrowserRouter leads to "404 Not Found - nginx " error when going to subpage directly without through a home-page click
- React router not working after building the app
- Create React App not showing error message with ErrorBoundary
- How to fix Next.js Vercel deployment module not found error
- Create React App not installing, showing an error and aborting installation
- Getting 403 ACCESS DENIED error when deploying React Web app on AWS Amplify
- eslint error on deployment on local server of react web app
- eslint error on deployment on local server of react web app
More Query from same tag
- Getting 404 error when fetching service-worker on next.js + firebase hosting pwa app
- Ternary condition on onclick event
- Handling selection of buttons + adding selected items to new array
- How to add styling to a JSX after its creation in React?
- Firebase getDownloadUrl does not work at first i neen to reload the page
- How can I add empty new fields by clicking on a button?
- simplify redux with generic action & reducer
- Repeated routes with React Router v4
- Could not proxy request /pusher/auth from localhost:3000 to http://localhost:5000 (ECONNREFUSED)
- Command Error : ( MongoServerError: bad auth : Authentication failed )
- Using react refs and forms
- How to properly access Redux store in the React component?
- Making a Styled component (img) behave like a button
- Is this expected behavior of react-router or a bug?
- How to pass event handlers to React-node in React-Recompose App
- Stopping a function from componentDidMount() after going to a different url
- Static elements interactions
- Navigate to page after authentication using React Router v4
- How to save new state to local json
- Load GLTF model in next.js / Error: Could not load <url> response.body.getReader is not a function
- Error: Objects are not valid as a React child (found: object with keys {id, name})
- checkbox onclick changing only after refreshing react js
- how to customize the shape height and width of a component from the props using react
- React JS - Invariant violation error while using HOC
- How to check and different sources sizes in *chunk.js
- Search filter in reactjs, say i have an array of data with multiple columns and rows
- Javascript(React) Object.keys and Object.getOwnPropertyNames are returning empty array
- Convert uploaded image to URL using FileReader
- Parsing Issues from API call return
- this.props returns undefined with array.map((item, i)