Skip to content

Commit e11756d

Browse files
committed
🚧 correct hook call for getProject
1 parent 0633c3b commit e11756d

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

client/modules/Mobile/MobileSketchView.jsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import React, { useState } from 'react';
1+
import React, { useState, useEffect } from 'react';
22
import PropTypes from 'prop-types';
33
import { Link } from 'react-router';
4+
import { bindActionCreators } from 'redux';
45
import { connect } from 'react-redux';
56
import styled from 'styled-components';
67
import Header from '../../components/mobile/Header';
78
import PreviewFrame from '../IDE/components/PreviewFrame';
89
import Screen from '../../components/mobile/MobileScreen';
10+
import * as ProjectActions from '../IDE/actions/project';
911
import { getHTMLFile, getJSFiles, getCSSFiles } from '../IDE/reducers/files';
1012

13+
1114
import { ExitIcon } from '../../common/Icons';
1215
import { remSize } from '../../theme';
1316

@@ -28,16 +31,22 @@ const noop = () => {};
2831
const MobileSketchView = (props) => {
2932
const [overlay, setOverlay] = useState(null);
3033

34+
3135
// TODO: useSelector requires react-redux ^7.1.0
3236
// const htmlFile = useSelector(state => getHTMLFile(state.files));
3337
// const jsFiles = useSelector(state => getJSFiles(state.files));
3438
// const cssFiles = useSelector(state => getCSSFiles(state.files));
3539
// const files = useSelector(state => state.files);
3640

3741
const {
38-
htmlFile, jsFiles, cssFiles, files
42+
htmlFile, jsFiles, cssFiles, files, params, getProject
3943
} = props;
4044

45+
useEffect(() => {
46+
console.log(params);
47+
getProject(params.project_id, params.username);
48+
}, []);
49+
4150
return (
4251
<Screen>
4352
<Header>
@@ -87,6 +96,10 @@ const MobileSketchView = (props) => {
8796
};
8897

8998
MobileSketchView.propTypes = {
99+
params: PropTypes.shape({
100+
project_id: PropTypes.string,
101+
username: PropTypes.string
102+
}).isRequired,
90103
htmlFile: PropTypes.shape({
91104
id: PropTypes.string.isRequired,
92105
content: PropTypes.string.isRequired,
@@ -107,16 +120,21 @@ MobileSketchView.propTypes = {
107120
content: PropTypes.string.isRequired,
108121
name: PropTypes.string.isRequired
109122
})).isRequired,
123+
getProject: PropTypes.func.isRequired,
110124
};
111125

112126
function mapStateToProps(state) {
113127
return {
114128
htmlFile: getHTMLFile(state.files),
115129
jsFiles: getJSFiles(state.files),
116130
cssFiles: getCSSFiles(state.files),
131+
project: state.project,
117132
files: state.files
118133
};
119134
}
120135

136+
function mapDispatchToProps(dispatch) {
137+
return bindActionCreators(ProjectActions, dispatch);
138+
}
121139

122-
export default connect(mapStateToProps)(MobileSketchView);
140+
export default connect(mapStateToProps, mapDispatchToProps)(MobileSketchView);

0 commit comments

Comments
 (0)