feat(client): ts-migrate layoutSelector component (#42748)

This commit is contained in:
ABHINAV SHARMA
2021-07-12 12:35:01 +05:30
committed by GitHub
parent a33584fd5b
commit e2ca65c803
4 changed files with 18 additions and 12 deletions

View File

@ -6,7 +6,7 @@ import { I18nextProvider } from 'react-i18next';
import i18n from './i18n/config'; import i18n from './i18n/config';
import { createStore } from './src/redux/createStore'; import { createStore } from './src/redux/createStore';
import AppMountNotifier from './src/components/app-mount-notifier'; import AppMountNotifier from './src/components/app-mount-notifier';
import layoutSelector from './utils/gatsby/layoutSelector'; import layoutSelector from './utils/gatsby/layout-selector';
const store = createStore(); const store = createStore();

View File

@ -5,7 +5,7 @@ import { I18nextProvider } from 'react-i18next';
import i18n from './i18n/config'; import i18n from './i18n/config';
import { createStore } from './src/redux/createStore'; import { createStore } from './src/redux/createStore';
import layoutSelector from './utils/gatsby/layoutSelector'; import layoutSelector from './utils/gatsby/layout-selector';
import { getheadTagComponents, getPostBodyComponents } from './utils/tags'; import { getheadTagComponents, getPostBodyComponents } from './utils/tags';
const store = createStore(); const store = createStore();

View File

@ -1,6 +1,4 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { import {
CertificationLayout, CertificationLayout,
DefaultLayout DefaultLayout
@ -8,7 +6,21 @@ import {
import FourOhFourPage from '../../src/pages/404'; import FourOhFourPage from '../../src/pages/404';
import { isChallenge } from '../../src/utils/path-parsers'; import { isChallenge } from '../../src/utils/path-parsers';
export default function layoutSelector({ element, props }) { interface Location {
pathname: string;
}
interface LayoutSelectorProps {
props: {
location: Location;
};
element: React.ReactElement;
}
export default function layoutSelector({
element,
props
}: LayoutSelectorProps): React.ReactElement {
const { const {
location: { pathname } location: { pathname }
} = props; } = props;
@ -37,9 +49,3 @@ export default function layoutSelector({ element, props }) {
); );
} }
} }
layoutSelector.propTypes = {
element: PropTypes.any,
location: PropTypes.objectOf({ pathname: PropTypes.string }),
props: PropTypes.any
};

View File

@ -2,7 +2,7 @@ import React from 'react';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import ShallowRenderer from 'react-test-renderer/shallow'; import ShallowRenderer from 'react-test-renderer/shallow';
import layoutSelector from './layoutSelector'; import layoutSelector from './layout-selector';
import { createStore } from '../../src/redux/createStore'; import { createStore } from '../../src/redux/createStore';
import FourOhFourPage from '../../src/pages/404'; import FourOhFourPage from '../../src/pages/404';
import Learn from '../../src/pages/learn'; import Learn from '../../src/pages/learn';