mirror of
https://github.com/scratchfoundation/scratch-desktop.git
synced 2024-12-23 06:02:30 -05:00
move ReactDOM.render() into index.js
This also means we no longer need to disable eslint's "no-unused-expressions" rule for each route in index.js
This commit is contained in:
parent
73819d8eb7
commit
371bd60a7d
4 changed files with 15 additions and 11 deletions
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
|
||||||
import {productName, version} from '../../package.json';
|
import {productName, version} from '../../package.json';
|
||||||
|
|
||||||
import logo from '../icon/ScratchDesktop.svg';
|
import logo from '../icon/ScratchDesktop.svg';
|
||||||
|
@ -37,5 +36,4 @@ const AboutElement = () => (
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
const appTarget = document.getElementById('app');
|
export default <AboutElement />;
|
||||||
ReactDOM.render(<AboutElement />, appTarget);
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ import bindAll from 'lodash.bindall';
|
||||||
import omit from 'lodash.omit';
|
import omit from 'lodash.omit';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
|
||||||
import {connect} from 'react-redux';
|
import {connect} from 'react-redux';
|
||||||
import {compose} from 'redux';
|
import {compose} from 'redux';
|
||||||
import GUI from 'scratch-gui/src/index';
|
import GUI from 'scratch-gui/src/index';
|
||||||
|
@ -181,4 +180,4 @@ const WrappedGui = compose(
|
||||||
ScratchDesktopHOC
|
ScratchDesktopHOC
|
||||||
)(GUI);
|
)(GUI);
|
||||||
|
|
||||||
ReactDOM.render(<WrappedGui />, appTarget);
|
export default <WrappedGui />;
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
import {ipcRenderer} from 'electron';
|
import {ipcRenderer} from 'electron';
|
||||||
|
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
|
|
||||||
ipcRenderer.on('ready-to-show', () => {
|
ipcRenderer.on('ready-to-show', () => {
|
||||||
// Start without any element in focus, otherwise the first link starts with focus and shows an orange box.
|
// Start without any element in focus, otherwise the first link starts with focus and shows an orange box.
|
||||||
// We shouldn't disable that box or the focus behavior in case someone wants or needs to navigate that way.
|
// We shouldn't disable that box or the focus behavior in case someone wants or needs to navigate that way.
|
||||||
|
@ -11,14 +13,21 @@ ipcRenderer.on('ready-to-show', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = new URLSearchParams(window.location.search).get('route') || 'app';
|
const route = new URLSearchParams(window.location.search).get('route') || 'app';
|
||||||
|
let routeModulePromise;
|
||||||
switch (route) {
|
switch (route) {
|
||||||
case 'app':
|
case 'app':
|
||||||
import('./app.jsx'); // eslint-disable-line no-unused-expressions
|
routeModulePromise = import('./app.jsx');
|
||||||
break;
|
break;
|
||||||
case 'about':
|
case 'about':
|
||||||
import('./about.jsx'); // eslint-disable-line no-unused-expressions
|
routeModulePromise = import('./about.jsx');
|
||||||
break;
|
break;
|
||||||
case 'privacy':
|
case 'privacy':
|
||||||
import('./privacy.jsx');
|
routeModulePromise = import('./privacy.jsx');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
routeModulePromise.then(routeModule => {
|
||||||
|
const appTarget = document.getElementById('app');
|
||||||
|
const routeElement = routeModule.default;
|
||||||
|
ReactDOM.render(routeElement, appTarget);
|
||||||
|
});
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
|
||||||
|
|
||||||
import styles from './privacy.css';
|
import styles from './privacy.css';
|
||||||
|
|
||||||
|
@ -58,5 +57,4 @@ const PrivacyElement = () => (
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
const appTarget = document.getElementById('app');
|
export default <PrivacyElement />;
|
||||||
ReactDOM.render(<PrivacyElement />, appTarget);
|
|
||||||
|
|
Loading…
Reference in a new issue