Skip to content

Commit 6646a19

Browse files
authored
Merge branch 'develop' into refactor/file-selectors
2 parents 4efa20d + 31e64d5 commit 6646a19

File tree

14 files changed

+657
-682
lines changed

14 files changed

+657
-682
lines changed

.babelrc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,16 @@
5151
"development": {
5252
"plugins": [
5353
"babel-plugin-styled-components",
54-
"react-hot-loader/babel"
54+
"react-refresh/babel"
55+
],
56+
"presets": [
57+
[
58+
"@babel/preset-react",
59+
{
60+
"development": true,
61+
"runtime": "automatic"
62+
}
63+
]
5564
]
5665
}
5766
},

client/index.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { Suspense } from 'react';
22
import { render } from 'react-dom';
3-
import { hot } from 'react-hot-loader/root';
43
import { Provider } from 'react-redux';
54
import { Router } from 'react-router-dom';
65

@@ -30,11 +29,9 @@ const App = () => (
3029
</Provider>
3130
);
3231

33-
const HotApp = hot(App);
34-
3532
render(
3633
<Suspense fallback={<Loader />}>
37-
<HotApp />
34+
<App />
3835
</Suspense>,
3936
document.getElementById('root')
4037
);

client/modules/IDE/pages/FullView.jsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import PropTypes from 'prop-types';
21
import React, { useEffect, useState } from 'react';
32
import Helmet from 'react-helmet';
43
import { useDispatch, useSelector } from 'react-redux';
4+
import { useParams } from 'react-router-dom';
55
import PreviewFrame from '../components/PreviewFrame';
66
import PreviewNav from '../../../components/PreviewNav';
77
import { getProject } from '../actions/project';
@@ -14,14 +14,15 @@ import {
1414
import useInterval from '../hooks/useInterval';
1515
import RootPage from '../../../components/RootPage';
1616

17-
function FullView(props) {
17+
function FullView() {
1818
const dispatch = useDispatch();
1919
const project = useSelector((state) => state.project);
2020
const [isRendered, setIsRendered] = useState(false);
21+
const params = useParams();
2122

2223
useEffect(() => {
23-
dispatch(getProject(props.params.project_id, props.params.username));
24-
}, []);
24+
dispatch(getProject(params.project_id, params.username));
25+
}, [params]);
2526

2627
useEffect(() => {
2728
// if (isRendered) prevents startSketch() from being called twice
@@ -64,7 +65,7 @@ function FullView(props) {
6465
}}
6566
project={{
6667
name: project.name,
67-
id: props.params.project_id
68+
id: params.project_id
6869
}}
6970
/>
7071
<main className="preview-frame-holder">
@@ -74,11 +75,4 @@ function FullView(props) {
7475
);
7576
}
7677

77-
FullView.propTypes = {
78-
params: PropTypes.shape({
79-
project_id: PropTypes.string,
80-
username: PropTypes.string
81-
}).isRequired
82-
};
83-
8478
export default FullView;

client/modules/IDE/pages/IDEView.jsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import { Prompt } from 'react-router-dom';
3+
import { useLocation, Prompt } from 'react-router-dom';
44
import { bindActionCreators } from 'redux';
55
import { connect, useSelector } from 'react-redux';
66
import { useTranslation, withTranslation } from 'react-i18next';
@@ -50,11 +50,13 @@ function isOverlay(pathname) {
5050
return pathname === '/about' || pathname === '/feedback';
5151
}
5252

53-
function WarnIfUnsavedChanges({ currentLocation }) {
53+
function WarnIfUnsavedChanges() {
5454
const hasUnsavedChanges = useSelector((state) => state.ide.unsavedChanges);
5555

5656
const { t } = useTranslation();
5757

58+
const currentLocation = useLocation();
59+
5860
return (
5961
<Prompt
6062
when={hasUnsavedChanges}
@@ -73,12 +75,6 @@ function WarnIfUnsavedChanges({ currentLocation }) {
7375
);
7476
}
7577

76-
WarnIfUnsavedChanges.propTypes = {
77-
currentLocation: PropTypes.shape({
78-
pathname: PropTypes.string
79-
}).isRequired
80-
};
81-
8278
class IDEView extends React.Component {
8379
constructor(props) {
8480
super(props);

client/modules/IDE/pages/Legal.jsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect } from 'react';
2-
import PropTypes from 'prop-types';
2+
import { useHistory, useLocation } from 'react-router-dom';
33
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
44
import styled from 'styled-components';
55
import { useTranslation } from 'react-i18next';
@@ -8,7 +8,6 @@ import TermsOfUse from './TermsOfUse';
88
import CodeOfConduct from './CodeOfConduct';
99
import RootPage from '../../../components/RootPage';
1010
import Nav from '../../../components/Nav';
11-
import browserHistory from '../../../browserHistory';
1211
import { remSize, prop } from '../../../theme';
1312

1413
const StyledTabList = styled(TabList)`
@@ -29,9 +28,12 @@ const TabTitle = styled.p`
2928
}
3029
`;
3130

32-
function Legal({ location }) {
31+
function Legal() {
3332
const [selectedIndex, setSelectedIndex] = useState(0);
3433
const { t } = useTranslation();
34+
const location = useLocation();
35+
const history = useHistory();
36+
3537
useEffect(() => {
3638
if (location.pathname === '/privacy-policy') {
3739
setSelectedIndex(0);
@@ -46,13 +48,13 @@ function Legal({ location }) {
4648
if (index === lastIndex) return;
4749
if (index === 0) {
4850
setSelectedIndex(0);
49-
browserHistory.push('/privacy-policy');
51+
history.push('/privacy-policy');
5052
} else if (index === 1) {
5153
setSelectedIndex(1);
52-
browserHistory.push('/terms-of-use');
54+
history.push('/terms-of-use');
5355
} else if (index === 2) {
5456
setSelectedIndex(2);
55-
browserHistory.push('/code-of-conduct');
57+
history.push('/code-of-conduct');
5658
}
5759
}
5860

@@ -85,10 +87,4 @@ function Legal({ location }) {
8587
);
8688
}
8789

88-
Legal.propTypes = {
89-
location: PropTypes.shape({
90-
pathname: PropTypes.string
91-
}).isRequired
92-
};
93-
9490
export default Legal;

client/modules/Mobile/MobileDashboardView.jsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React from 'react';
2-
import PropTypes from 'prop-types';
32
import styled from 'styled-components';
43
import { useSelector } from 'react-redux';
5-
import { withRouter } from 'react-router-dom';
4+
import { useLocation, useParams } from 'react-router-dom';
65
import { useTranslation } from 'react-i18next';
76

87
import Screen from '../../components/mobile/MobileScreen';
@@ -178,10 +177,10 @@ const NavItem = styled.li`
178177
const renderPanel = (name, props) =>
179178
((Component) => Component && <Component {...props} mobile />)(Panels[name]);
180179

181-
const MobileDashboard = ({ params, location }) => {
180+
const MobileDashboard = () => {
182181
const user = useSelector((state) => state.user);
183-
const { username: paramsUsername } = params;
184-
const { pathname } = location;
182+
const { username: paramsUsername } = useParams();
183+
const { pathname } = useLocation();
185184
const { t } = useTranslation();
186185

187186
const Tabs = Object.keys(Panels);
@@ -253,14 +252,4 @@ const MobileDashboard = ({ params, location }) => {
253252
);
254253
};
255254

256-
MobileDashboard.propTypes = {
257-
location: PropTypes.shape({
258-
pathname: PropTypes.string.isRequired
259-
}).isRequired,
260-
params: PropTypes.shape({
261-
username: PropTypes.string.isRequired
262-
})
263-
};
264-
MobileDashboard.defaultProps = { params: {} };
265-
266-
export default withRouter(MobileDashboard);
255+
export default MobileDashboard;

client/modules/Preview/previewIndex.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useReducer, useState, useEffect } from 'react';
22
import { render } from 'react-dom';
3-
import { hot } from 'react-hot-loader/root';
43
import { createGlobalStyle } from 'styled-components';
54
import {
65
registerFrame,
@@ -73,6 +72,4 @@ const App = () => {
7372
);
7473
};
7574

76-
const HotApp = hot(App);
77-
78-
render(<HotApp />, document.getElementById('root'));
75+
render(<App />, document.getElementById('root'));

client/modules/User/pages/AccountView.jsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
32
import { useDispatch, useSelector } from 'react-redux';
43
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
54
import { Helmet } from 'react-helmet';
65
import { useTranslation } from 'react-i18next';
7-
import { withRouter } from 'react-router-dom';
6+
import { useHistory, useLocation } from 'react-router-dom';
87
import { parse } from 'query-string';
98
import { createApiKey, removeApiKey } from '../actions';
109
import AccountForm from '../components/AccountForm';
1110
import SocialAuthButton from '../components/SocialAuthButton';
1211
import APIKeyForm from '../components/APIKeyForm';
13-
import browserHistory from '../../../browserHistory';
1412
import Nav from '../../../components/Nav';
1513
import ErrorModal from '../../IDE/components/ErrorModal';
1614
import Overlay from '../../App/components/Overlay';
@@ -45,16 +43,18 @@ function SocialLoginPanel() {
4543
);
4644
}
4745

48-
function AccountView({ location }) {
46+
function AccountView() {
4947
const { t } = useTranslation();
5048

49+
const location = useLocation();
5150
const queryParams = parse(location.search);
5251
const showError = !!queryParams.error;
5352
const errorType = queryParams.error;
5453
const accessTokensUIEnabled = window.process.env.UI_ACCESS_TOKEN_ENABLED;
5554

5655
const apiKeys = useSelector((state) => state.user.apiKeys);
5756
const dispatch = useDispatch();
57+
const history = useHistory();
5858

5959
return (
6060
<div className="account-settings__container">
@@ -70,7 +70,7 @@ function AccountView({ location }) {
7070
title={t('ErrorModal.LinkTitle')}
7171
ariaLabel={t('ErrorModal.LinkTitle')}
7272
closeOverlay={() => {
73-
browserHistory.push(location.pathname);
73+
history.push(location.pathname);
7474
}}
7575
>
7676
<ErrorModal type="oauthError" service={errorType} />
@@ -119,11 +119,4 @@ function AccountView({ location }) {
119119
);
120120
}
121121

122-
AccountView.propTypes = {
123-
location: PropTypes.shape({
124-
search: PropTypes.string.isRequired,
125-
pathname: PropTypes.string.isRequired
126-
}).isRequired
127-
};
128-
129-
export default withRouter(AccountView);
122+
export default AccountView;

client/modules/User/pages/NewPasswordView.jsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import PropTypes from 'prop-types';
21
import React, { useEffect } from 'react';
32
import classNames from 'classnames';
43
import { useDispatch, useSelector } from 'react-redux';
54
import { Helmet } from 'react-helmet';
65
import { useTranslation } from 'react-i18next';
6+
import { useParams } from 'react-router-dom';
77
import NewPasswordForm from '../components/NewPasswordForm';
88
import { validateResetPasswordToken } from '../actions';
99
import Nav from '../../../components/Nav';
1010
import RootPage from '../../../components/RootPage';
1111

12-
function NewPasswordView(props) {
12+
function NewPasswordView() {
1313
const { t } = useTranslation();
14-
const resetPasswordToken = props.params.reset_password_token;
14+
const params = useParams();
15+
const resetPasswordToken = params.reset_password_token;
1516
const resetPasswordInvalid = useSelector(
1617
(state) => state.user.resetPasswordInvalid
1718
);
@@ -48,10 +49,4 @@ function NewPasswordView(props) {
4849
);
4950
}
5051

51-
NewPasswordView.propTypes = {
52-
params: PropTypes.shape({
53-
reset_password_token: PropTypes.string
54-
}).isRequired
55-
};
56-
5752
export default NewPasswordView;

0 commit comments

Comments
 (0)