Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Move OS class creation and darkMode init to after React loads #80

Merged
merged 1 commit into from
Jun 8, 2016

Conversation

paulmolluzzo
Copy link
Contributor

I was getting a couple of console errors and I fixed them by moving some things into the init() function which depends on React being ready. Specifically I moved adding the OS-specific class name to the document, and I also moved darkMode() since that depends on the DOM being ready.

See if you can replicate the errors on master, then test this branch. All I did was start the app and it occurred every time.

Errors:

/Users/paul/open_source/anatine/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources…:130 Unable to load preload script: /Users/paul/open_source/anatine/browser.js(anonymous function) @ /Users/paul/open_source/anatine/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources…:130
/Users/paul/open_source/anatine/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources…:131 TypeError: Cannot read property 'classList' of null
    at setDarkMode (/Users/paul/open_source/anatine/browser.js:160)
    at Object.<anonymous> (/Users/paul/open_source/anatine/browser.js:231)
    at Module._compile (module.js:541)
    at Object.Module._extensions..js (module.js:550)
    at Module.load (module.js:456)
    at tryModuleLoad (module.js:415)
    at Function.Module._load (module.js:407)
    at Module.require (module.js:466)
    at require (internal/module.js:20)
    at Object.<anonymous> (/Users/paul/open_source/anatine/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources…:128)

}

document.addEventListener('DOMContentLoaded', () => {
zoomInit();

// enable OS specific styles
document.documentElement.classList.add(`os-${process.platform}`);
Copy link
Owner

@sindresorhus sindresorhus Jun 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be moved.

@paulmolluzzo
Copy link
Contributor Author

@sindresorhus both fixed and the console errors are gone with your suggestions. Thanks.

@sindresorhus sindresorhus merged commit 5d7b53f into master Jun 8, 2016
@sindresorhus sindresorhus deleted the move-init-items branch June 8, 2016 23:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants