Skip to content

Commit e833414

Browse files
authored
Feature/upgrade react to 17 (#4227)
* upgrade react and react-dom * set runtime to automatic * upgrade @mdx-js/loader * remove unused React imports
1 parent 64e4231 commit e833414

File tree

39 files changed

+120
-146
lines changed

39 files changed

+120
-146
lines changed

.babelrc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
22
"presets": [
33
"@babel/preset-env",
4-
"@babel/preset-react"
5-
],
6-
"plugins": [
7-
"@babel/plugin-proposal-class-properties"
4+
[
5+
"@babel/preset-react",
6+
{
7+
"runtime": "automatic"
8+
}
9+
]
810
],
11+
"plugins": ["@babel/plugin-proposal-class-properties"],
912
"env": {
1013
"development": {
11-
"plugins": [
12-
"react-refresh/babel"
13-
]
14+
"plugins": ["react-refresh/babel"]
1415
}
1516
}
1617
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"@babel/plugin-proposal-class-properties": "^7.10.4",
8484
"@babel/preset-env": "^7.11.5",
8585
"@babel/preset-react": "^7.10.4",
86-
"@mdx-js/loader": "^1.6.16",
86+
"@mdx-js/loader": "^1.6.21",
8787
"@octokit/auth-action": "^1.3.0",
8888
"@octokit/rest": "^18.0.5",
8989
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.2",
@@ -159,10 +159,10 @@
159159
"lodash.throttle": "^4.1.1",
160160
"path-browserify": "^1.0.1",
161161
"prop-types": "^15.7.2",
162-
"react": "^16.8.6",
162+
"react": "^17.0.1",
163163
"react-banner": "^1.0.0-rc.0",
164164
"react-document-title": "^2.0.3",
165-
"react-dom": "^16.8.6",
165+
"react-dom": "^17.0.1",
166166
"react-g-analytics": "0.4.2",
167167
"react-router-dom": "^5.2.0",
168168
"react-tiny-popover": "5",

src/components/Configuration/Configuration.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import React from 'react';
1+
import { Children, isValidElement } from 'react';
22
import { Details } from './components';
33

44
const detailComponentsList = ['link', 'mode', 'entry', 'path', 'filename', 'publicPath', 'library', 'libraryType', 'libraryName', 'advancedLibrary', 'advancedOutput', 'expertOutput', 'expertOutputB', 'expert', 'advancedConditions', 'moduleType', 'advancedActions', 'advancedModule', 'modules', 'alias', 'advancedResolve', 'expertResolve', 'hints', 'devtool', 'target', 'externals', 'externalsType', 'externalsPresets', 'ignoreWarnings', 'stats', 'preset', 'advancedGlobal', 'advancedAssets', 'advancedChunkGroups', 'advancedChunks', 'advancedModules', 'expertModules', 'advancedStatsOptimization', 'advancedOptimization', 'cacheGroupAdvancedSelectors', 'cacheGroupAdvancedEffects', 'advancedSelectors', 'advancedEffects', 'fallbackCacheGroup', 'advanced', 'advancedCaching', 'advancedBuild'];
55

66
export const Pre = props => {
7-
const newChildren = React.Children.map(props.children.props.children, child => {
8-
if (React.isValidElement(child)) {
7+
const newChildren = Children.map(props.children.props.children, child => {
8+
if (isValidElement(child)) {
99
if (child.props.className.includes('keyword')) {
1010
if (!detailComponentsList.includes(child.props.componentname)) return child;
1111

12-
return <Details children={child.props.children.slice(4, React.Children.count(child.props.children) - 4)} url={child.props.url} />;
12+
return <Details children={child.props.children.slice(4, Children.count(child.props.children) - 4)} url={child.props.url} />;
1313
}
1414
}
1515

src/components/Configuration/components.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { isValidElement, Component } from 'react';
22
import Popover from 'react-tiny-popover';
33
import './Configuration.scss';
44
import { timeout } from 'q';
@@ -29,7 +29,7 @@ const Card = ({ body }) => {
2929
);
3030
};
3131

32-
export class Details extends React.Component {
32+
export class Details extends Component {
3333
constructor(props) {
3434
super(props);
3535
this.state = {
@@ -50,7 +50,7 @@ export class Details extends React.Component {
5050

5151
// Find the index of </default>
5252
const closeDefaultTagIndex = children.findIndex(child => {
53-
if (React.isValidElement(child)) {
53+
if (isValidElement(child)) {
5454
return (
5555
child.props.className.includes('tag') &&
5656
child.props.children.length === DEFAULT_CHILDREN_SIZE

src/components/Container/Container.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import './Container.scss';
32

43
export default (props = {}) => {

src/components/Contributors/Contributors.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React from 'react';
1+
import { Component } from 'react';
22
import VisibilitySensor from 'react-visibility-sensor';
33
import SmallIcon from '../../assets/icon-square-small-slack.png';
44
import './Contributors.scss';
55

6-
export default class Contributors extends React.Component {
6+
export default class Contributors extends Component {
77
state = {
88
inView: false
99
}

src/components/Cube/Cube.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Import External Dependencies
2-
import React from 'react';
2+
import { Component } from 'react';
33
import PropTypes from 'prop-types';
44

55
// Load Styling
66
import './Cube.scss';
77

8-
export default class Cube extends React.Component {
8+
export default class Cube extends Component {
99
static propTypes = {
1010
hover: PropTypes.bool,
1111
theme: PropTypes.string,

src/components/Dropdown/Dropdown.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React from 'react';
1+
import { Component } from 'react';
22
import LanguageIcon from '../../assets/language-icon.svg';
33
import './Dropdown.scss';
44

5-
export default class Dropdown extends React.Component {
5+
export default class Dropdown extends Component {
66
state = {
77
active: false
88
};

src/components/Footer/Footer.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import Link from '../Link/Link';
32
import Container from '../Container/Container';
43
import Icon from '../../assets/icon-square-small.svg';

src/components/Gitter/Gitter.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Import External Dependencies
2-
import React from 'react';
2+
import { Component } from 'react';
33

44
// Import Utilities
55
import isClient from '../../utilities/is-client';
@@ -13,7 +13,7 @@ let sidecar = null;
1313
let sidecarLoadTriggered = false;
1414

1515
// Create and export component
16-
export default class Gitter extends React.Component {
16+
export default class Gitter extends Component {
1717
render() {
1818
return (
1919
<div className="gitter">

src/components/Link/Link.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { Link } from 'react-router-dom';
32

43
export default ({

src/components/Logo/Logo.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import Logo from '../../assets/site-logo.svg';
32
import './Logo.scss';
43

src/components/Markdown/Markdown.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import './Markdown.scss';
32

43
const Markdown = props => (

src/components/Navigation/Navigation.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Import External Dependencies
2-
import React from 'react';
2+
import { Component } from 'react';
33
import Banner from 'react-banner';
44

55
// Import Components
@@ -21,7 +21,7 @@ import StackOverflowIcon from '../../styles/icons/stack-overflow.svg';
2121

2222
const onSearch = () => {};
2323

24-
export default class Navigation extends React.Component {
24+
export default class Navigation extends Component {
2525
render() {
2626
let { pathname, links, toggleSidebar } = this.props;
2727

src/components/NotificationBar/NotificationBar.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { Component, Fragment } from 'react';
22
import Container from '../Container/Container';
33
import testLocalStorage from '../../utilities/test-local-storage';
44
import './NotificationBar.scss';
@@ -14,7 +14,7 @@ const barDismissed = () => {
1414
return false;
1515
};
1616

17-
class MessageBar extends React.Component {
17+
class MessageBar extends Component {
1818
render() {
1919
return (
2020
<div className="notification-bar">
@@ -48,7 +48,7 @@ class MessageBar extends React.Component {
4848
}
4949
}
5050

51-
export default class NotificationBar extends React.Component {
51+
export default class NotificationBar extends Component {
5252
constructor(props) {
5353
super(props);
5454
this.onClose = this.onClose.bind(this);
@@ -74,6 +74,6 @@ export default class NotificationBar extends React.Component {
7474
render() {
7575
const { dismissed } = this.state;
7676

77-
return <React.Fragment>{!dismissed ? <MessageBar onClose={this.onClose} /> : null}</React.Fragment>;
77+
return <Fragment>{!dismissed ? <MessageBar onClose={this.onClose} /> : null}</Fragment>;
7878
}
7979
}

src/components/Organization/Organization.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import Container from '../Container/Container';
32
import Contributors from '../Contributors/Contributors';
43
import Link from '../Link/Link';

src/components/Page/AdjacentPages.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import Link from '../Link/Link';
32
import './AdjacentPages.scss';
43
import PropTypes from 'prop-types';

src/components/Page/Page.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Import External Dependencies
2-
import React from 'react';
2+
import { Children, isValidElement, Component } from 'react';
33

44
// Import Components
55
import PageLinks from '../PageLinks/PageLinks';
@@ -12,7 +12,7 @@ import AdjacentPages from './AdjacentPages';
1212
// Load Styling
1313
import './Page.scss';
1414

15-
class Page extends React.Component {
15+
class Page extends Component {
1616
constructor(props) {
1717
super(props);
1818

@@ -69,8 +69,8 @@ class Page extends React.Component {
6969

7070
if (typeof content === 'function') {
7171
contentRender = content({}).props.children.slice(4); // Cut frontmatter information
72-
contentRender = React.Children.map(contentRender, child => {
73-
if (React.isValidElement(child)) {
72+
contentRender = Children.map(contentRender, child => {
73+
if (isValidElement(child)) {
7474
if (child.props.mdxType === 'pre') {
7575
return <Pre children={child.props.children} />;
7676
}

src/components/PageLinks/PageLinks.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import Url from 'url';
32
import './PageLinks.scss';
43
import icon from '../../assets/icon-print.svg';

src/components/PageNotFound/PageNotFound.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { Link } from 'react-router-dom';
32

43
// Styles

src/components/Placeholder/Placeholder.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import React from 'react';
2-
3-
// Import Styling
41
import './Placeholder.scss';
52

63
// Placeholder string

src/components/Print/Print.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
// Load Styling
31
import './Print.scss';
42
import icon from '../../assets/icon-print.svg';
53
import BarIcon from '../../styles/icons/vertical-bar.svg';

src/components/Print/PrintScript.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
const printScript = `
42
window.matchMedia('print').addListener(function(mql) {
53
if (!mql.matches) {

src/components/Shield/Shield.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
export default props => (
42
<img alt="webpack shield" src={
53
`https://img.shields.io/${props.content}.svg?label=${props.label}&style=flat-square&maxAge=3600`

src/components/Sidebar/Sidebar.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
// Import External Dependencies
2-
import React from 'react';
3-
4-
// Import Local Components
52
import Shield from '../Shield/Shield';
63
import SidebarItem from '../SidebarItem/SidebarItem';
74
import Print from '../Print/Print';

src/components/SidebarItem/SidebarItem.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { Component } from 'react';
22
import Link from '../Link/Link';
33
import './SidebarItem.scss';
44
import list2Tree from '../../utilities/list2Tree';
@@ -7,7 +7,7 @@ import BarIcon from '../../styles/icons/vertical-bar.svg';
77

88
const block = 'sidebar-item';
99

10-
export default class SidebarItem extends React.Component {
10+
export default class SidebarItem extends Component {
1111
state = {
1212
open: this._isOpen(this.props)
1313
};

src/components/SidebarMobile/SidebarMobile.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React from 'react';
1+
import { Component } from 'react';
22
import Link from '../Link/Link';
33
import './SidebarMobile.scss';
44
import CloseIcon from '../../styles/icons/cross.svg';
55

66
// TODO: Check to make sure all pages are shown and properly sorted
7-
export default class SidebarMobile extends React.Component {
7+
export default class SidebarMobile extends Component {
88
_container = null
99
_initialTouchPosition = {}
1010
_lastTouchPosition = {}

src/components/Site/Site.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Import External Dependencies
2-
import React from 'react';
2+
import { Component, Fragment } from 'react';
33
import { Switch, Route, Redirect } from 'react-router-dom';
44
import DocumentTitle from 'react-document-title';
55

@@ -48,7 +48,7 @@ if (isClient) {
4848
}
4949
}
5050

51-
class Site extends React.Component {
51+
class Site extends Component {
5252
state = {
5353
mobileSidebarOpen: false
5454
};
@@ -103,7 +103,7 @@ class Site extends React.Component {
103103
<Route path="/vote" component={Vote} />
104104
<Route path="/organization" component={Organization} />
105105
<Route path="/starter-kits" component={StarterKits} />
106-
<Route path="/app-shell" component={() => <React.Fragment />} />
106+
<Route path="/app-shell" component={() => <Fragment />} />
107107
{pages.map(page => (
108108
<Route
109109
key={page.url}
@@ -118,7 +118,7 @@ class Site extends React.Component {
118118
'url'
119119
);
120120
return (
121-
<React.Fragment>
121+
<Fragment>
122122
<Sponsors />
123123
<Sidebar
124124
className="site__sidebar"
@@ -132,7 +132,7 @@ class Site extends React.Component {
132132
next={next}
133133
/>
134134
<Gitter />
135-
</React.Fragment>
135+
</Fragment>
136136
);
137137
}}
138138
/>

0 commit comments

Comments
 (0)