Skip to content

Instantly share code, notes, and snippets.

@pshubham95
Created August 11, 2019 11:12
Show Gist options
  • Save pshubham95/6427a1d307b00d9c6298a76a7b50812b to your computer and use it in GitHub Desktop.
Save pshubham95/6427a1d307b00d9c6298a76a7b50812b to your computer and use it in GitHub Desktop.
index.js configured with ondeviceready event
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
const renderReactDom = () => {
ReactDOM.render(<App />, document.getElementById('root'));
};
if (window.cordova) {
document.addEventListener('deviceready', () => {
renderReactDom();
}, false);
} else {
renderReactDom();
}
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment