1
- import React , { useState } from 'react' ;
1
+ import React , { useState , useEffect } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
3
import { Link } from 'react-router' ;
4
+ import { bindActionCreators } from 'redux' ;
4
5
import { connect } from 'react-redux' ;
5
6
import styled from 'styled-components' ;
6
7
import Header from '../../components/mobile/Header' ;
7
8
import PreviewFrame from '../IDE/components/PreviewFrame' ;
8
9
import Screen from '../../components/mobile/MobileScreen' ;
10
+ import * as ProjectActions from '../IDE/actions/project' ;
9
11
import { getHTMLFile , getJSFiles , getCSSFiles } from '../IDE/reducers/files' ;
10
12
13
+
11
14
import { ExitIcon } from '../../common/Icons' ;
12
15
import { remSize } from '../../theme' ;
13
16
@@ -28,16 +31,22 @@ const noop = () => {};
28
31
const MobileSketchView = ( props ) => {
29
32
const [ overlay , setOverlay ] = useState ( null ) ;
30
33
34
+
31
35
// TODO: useSelector requires react-redux ^7.1.0
32
36
// const htmlFile = useSelector(state => getHTMLFile(state.files));
33
37
// const jsFiles = useSelector(state => getJSFiles(state.files));
34
38
// const cssFiles = useSelector(state => getCSSFiles(state.files));
35
39
// const files = useSelector(state => state.files);
36
40
37
41
const {
38
- htmlFile, jsFiles, cssFiles, files
42
+ htmlFile, jsFiles, cssFiles, files, params , getProject
39
43
} = props ;
40
44
45
+ useEffect ( ( ) => {
46
+ console . log ( params ) ;
47
+ getProject ( params . project_id , params . username ) ;
48
+ } , [ ] ) ;
49
+
41
50
return (
42
51
< Screen >
43
52
< Header >
@@ -87,6 +96,10 @@ const MobileSketchView = (props) => {
87
96
} ;
88
97
89
98
MobileSketchView . propTypes = {
99
+ params : PropTypes . shape ( {
100
+ project_id : PropTypes . string ,
101
+ username : PropTypes . string
102
+ } ) . isRequired ,
90
103
htmlFile : PropTypes . shape ( {
91
104
id : PropTypes . string . isRequired ,
92
105
content : PropTypes . string . isRequired ,
@@ -107,16 +120,21 @@ MobileSketchView.propTypes = {
107
120
content : PropTypes . string . isRequired ,
108
121
name : PropTypes . string . isRequired
109
122
} ) ) . isRequired ,
123
+ getProject : PropTypes . func . isRequired ,
110
124
} ;
111
125
112
126
function mapStateToProps ( state ) {
113
127
return {
114
128
htmlFile : getHTMLFile ( state . files ) ,
115
129
jsFiles : getJSFiles ( state . files ) ,
116
130
cssFiles : getCSSFiles ( state . files ) ,
131
+ project : state . project ,
117
132
files : state . files
118
133
} ;
119
134
}
120
135
136
+ function mapDispatchToProps ( dispatch ) {
137
+ return bindActionCreators ( ProjectActions , dispatch ) ;
138
+ }
121
139
122
- export default connect ( mapStateToProps ) ( MobileSketchView ) ;
140
+ export default connect ( mapStateToProps , mapDispatchToProps ) ( MobileSketchView ) ;
0 commit comments