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

Browser error - Cannot assign to read only property 'window' of object '#<Window>' #332

Open
Shooshte opened this issue Nov 27, 2018 · 0 comments

Comments

@Shooshte
Copy link

I am trying to use IndexedDbShim with a react application. I am using create-react-app and this is the main app index.js file that runs before everything else:

import '@babel/polyfill';

import React from 'react';
import ReactDOM from 'react-dom';
import { toJS } from 'mobx';
import AsyncLoad from './common/components/AsyncComponent';

import { setGlobalVars } from 'indexeddbshim';

global.window = global; // We'll allow ourselves to use `window.indexedDB` or `indexedDB` as a global
setGlobalVars(); // See signature below
...
// unrelated code continues here

I am getting the following error in the console:

Uncaught TypeError: Cannot assign to read only property 'window' of object '#'
at Object. (index.js:10)
at Object../src/index.js (index.js:35)
at webpack_require (bootstrap 8babaf20081f9cc7653e:698)
at fn (bootstrap 8babaf20081f9cc7653e:111)
at Object.0 (index.js:35)
at webpack_require (bootstrap 8babaf20081f9cc7653e:698)
at bootstrap 8babaf20081f9cc7653e:796
at bootstrap 8babaf20081f9cc7653e:796

Is there a known workaround for this? Or is there a polyfill version that ships as a single file that I can use as a static dependencies (webpack bundles my node_modules code so I cannot just include the npm install in my static html files).

Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants