1- import PropTypes from 'prop-types' ;
21import React , { useState , useCallback } from 'react' ;
3- import { connect } from 'react-redux' ;
2+ import { useDispatch , useSelector } from 'react-redux' ;
43import MediaQuery from 'react-responsive' ;
5- import { withTranslation } from 'react-i18next' ;
4+ import { useLocation , useParams } from 'react-router-dom' ;
5+ import { useTranslation } from 'react-i18next' ;
66
77import Button from '../../../common/Button' ;
88import Nav from '../../IDE/components/Header/Nav' ;
@@ -12,7 +12,7 @@ import AssetSize from '../../IDE/components/AssetSize';
1212import CollectionList from '../../IDE/components/CollectionList' ;
1313import SketchList from '../../IDE/components/SketchList' ;
1414import RootPage from '../../../components/RootPage' ;
15- import * as ProjectActions from '../../IDE/actions/project' ;
15+ import { newProject } from '../../IDE/actions/project' ;
1616import {
1717 CollectionSearchbar ,
1818 SketchSearchbar
@@ -23,11 +23,20 @@ import DashboardTabSwitcherPublic, {
2323 TabKey
2424} from '../components/DashboardTabSwitcher' ;
2525
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+
2736 const [ collectionCreateVisible , setCollectionCreateVisible ] = useState ( false ) ;
2837
2938 const createNewSketch = ( ) => {
30- newProject ( ) ;
39+ dispatch ( newProject ( ) ) ;
3140 } ;
3241
3342 const selectedTabKey = useCallback ( ( ) => {
@@ -142,33 +151,4 @@ const DashboardView = ({ newProject, location, params, user, t }) => {
142151 ) ;
143152} ;
144153
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