feat(client): ts-migration for the Mobile Layout component (#44082)

* chore: rename the file MobileLayout.js to tsx

* refactor: refactor the file MobileLayout to TS

Co-authored-by: IsmailTlemcani <ismail.tlemcani@gmail.com>
This commit is contained in:
Ismail Tlemcani
2021-11-10 09:29:19 +01:00
committed by GitHub
parent 26319e0094
commit 8d6d210d82
2 changed files with 16 additions and 19 deletions

View File

@@ -1,10 +1,9 @@
import { TabPane, Tabs } from '@freecodecamp/react-bootstrap'; import { TabPane, Tabs } from '@freecodecamp/react-bootstrap';
import i18next from 'i18next'; import i18next from 'i18next';
import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators, Dispatch } from 'redux';
import { createStructuredSelector } from 'reselect'; import { createStructuredSelector } from 'reselect';
import envData from '../../../../../config/env.json'; import envData from '../../../../../config/env.json';
import ToolPanel from '../components/tool-panel'; import ToolPanel from '../components/tool-panel';
@@ -17,27 +16,26 @@ const mapStateToProps = createStructuredSelector({
currentTab: currentTabSelector currentTab: currentTabSelector
}); });
const mapDispatchToProps = dispatch => const mapDispatchToProps = (dispatch: Dispatch) =>
bindActionCreators( bindActionCreators(
{ {
moveToTab moveToTab
}, },
dispatch dispatch
); );
interface MobileLayoutProps {
const propTypes = { currentTab: number;
currentTab: PropTypes.number, editor: JSX.Element | null;
editor: PropTypes.element, guideUrl: string;
guideUrl: PropTypes.string, hasPreview: boolean;
hasPreview: PropTypes.bool, instructions: JSX.Element;
instructions: PropTypes.element, moveToTab: typeof moveToTab;
moveToTab: PropTypes.func, preview: JSX.Element;
preview: PropTypes.element, testOutput: JSX.Element;
testOutput: PropTypes.element, videoUrl: string;
videoUrl: PropTypes.string }
}; class MobileLayout extends Component<MobileLayoutProps> {
static displayName: string;
class MobileLayout extends Component {
componentDidMount() { componentDidMount() {
if (this.props.currentTab !== 1) this.props.moveToTab(1); if (this.props.currentTab !== 1) this.props.moveToTab(1);
} }
@@ -101,6 +99,5 @@ class MobileLayout extends Component {
} }
MobileLayout.displayName = 'MobileLayout'; MobileLayout.displayName = 'MobileLayout';
MobileLayout.propTypes = propTypes;
export default connect(mapStateToProps, mapDispatchToProps)(MobileLayout); export default connect(mapStateToProps, mapDispatchToProps)(MobileLayout);

View File

@@ -44,9 +44,9 @@ import {
updateChallengeMeta updateChallengeMeta
} from '../redux'; } from '../redux';
import { getGuideUrl } from '../utils'; import { getGuideUrl } from '../utils';
import MobileLayout from './MobileLayout';
import MultifileEditor from './MultifileEditor'; import MultifileEditor from './MultifileEditor';
import DesktopLayout from './desktop-layout'; import DesktopLayout from './desktop-layout';
import MobileLayout from './mobile-layout';
import './classic.css'; import './classic.css';
import '../components/test-frame.css'; import '../components/test-frame.css';