1
- import PropTypes from 'prop-types' ;
2
1
import React , { useState , useCallback } from 'react' ;
3
- import { connect } from 'react-redux' ;
2
+ import { useDispatch , useSelector } from 'react-redux' ;
4
3
import MediaQuery from 'react-responsive' ;
5
- import { withTranslation } from 'react-i18next' ;
4
+ import { useLocation , useParams } from 'react-router-dom' ;
5
+ import { useTranslation } from 'react-i18next' ;
6
6
7
7
import Button from '../../../common/Button' ;
8
8
import Nav from '../../IDE/components/Header/Nav' ;
@@ -12,7 +12,7 @@ import AssetSize from '../../IDE/components/AssetSize';
12
12
import CollectionList from '../../IDE/components/CollectionList' ;
13
13
import SketchList from '../../IDE/components/SketchList' ;
14
14
import RootPage from '../../../components/RootPage' ;
15
- import * as ProjectActions from '../../IDE/actions/project' ;
15
+ import { newProject } from '../../IDE/actions/project' ;
16
16
import {
17
17
CollectionSearchbar ,
18
18
SketchSearchbar
@@ -23,11 +23,20 @@ import DashboardTabSwitcherPublic, {
23
23
TabKey
24
24
} from '../components/DashboardTabSwitcher' ;
25
25
26
- const DashboardView = ( { newProject, location, params, user, t } ) => {
26
+ const DashboardView = ( ) => {
27
+ const { t } = useTranslation ( ) ;
28
+
29
+ const params = useParams ( ) ;
30
+ const location = useLocation ( ) ;
31
+
32
+ const dispatch = useDispatch ( ) ;
33
+
34
+ const user = useSelector ( ( state ) => state . user ) ;
35
+
27
36
const [ collectionCreateVisible , setCollectionCreateVisible ] = useState ( false ) ;
28
37
29
38
const createNewSketch = ( ) => {
30
- newProject ( ) ;
39
+ dispatch ( newProject ( ) ) ;
31
40
} ;
32
41
33
42
const selectedTabKey = useCallback ( ( ) => {
@@ -142,33 +151,4 @@ const DashboardView = ({ newProject, location, params, user, t }) => {
142
151
) ;
143
152
} ;
144
153
145
- DashboardView . defaultProps = {
146
- user : null
147
- } ;
148
-
149
- DashboardView . propTypes = {
150
- newProject : PropTypes . func . isRequired ,
151
- location : PropTypes . shape ( {
152
- pathname : PropTypes . string . isRequired
153
- } ) . isRequired ,
154
- params : PropTypes . shape ( {
155
- username : PropTypes . string . isRequired
156
- } ) . isRequired ,
157
- user : PropTypes . shape ( {
158
- username : PropTypes . string
159
- } ) ,
160
- t : PropTypes . func . isRequired
161
- } ;
162
-
163
- const mapStateToProps = ( state ) => ( {
164
- previousPath : state . ide . previousPath ,
165
- user : state . user
166
- } ) ;
167
-
168
- const mapDispatchToProps = {
169
- ...ProjectActions
170
- } ;
171
-
172
- export default withTranslation ( ) (
173
- connect ( mapStateToProps , mapDispatchToProps ) ( DashboardView )
174
- ) ;
154
+ export default DashboardView ;
0 commit comments