diff --git a/package.json b/package.json index f2f8eebd5fab233e1322c4af22a46dad5c660737..0e4d422469e76e0c054af5164ace6bf4d5df0a44 100755 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "dependencies": { "@antv/data-set": "^0.8.0", "@babel/polyfill": "^7.0.0-beta.36", - "@types/react": "^16.3.5", - "@types/react-dom": "^16.0.4", + "@types/react": "^16.3.8", + "@types/react-dom": "^16.0.5", "antd": "^3.4.0", "babel-runtime": "^6.9.2", "bizcharts": "^3.1.3-beta.1", diff --git a/src/components/PageHeader/index.js b/src/components/PageHeader/index.js index a36fa7f15e5472bbf0fb3f611845008a8115ce26..f4dab5c1021e301dc9e33215fd78abefcea9a0d4 100644 --- a/src/components/PageHeader/index.js +++ b/src/components/PageHeader/index.js @@ -1,5 +1,4 @@ import React, { PureComponent, createElement } from 'react'; -import PropTypes from 'prop-types'; import pathToRegexp from 'path-to-regexp'; import { Breadcrumb, Tabs } from 'antd'; import classNames from 'classnames'; @@ -20,12 +19,6 @@ export function getBreadcrumb(breadcrumbNameMap, url) { } export default class PageHeader extends PureComponent { - static contextTypes = { - routes: PropTypes.array, - params: PropTypes.object, - location: PropTypes.object, - breadcrumbNameMap: PropTypes.object, - }; onChange = key => { if (this.props.onTabChange) { this.props.onTabChange(key); @@ -33,10 +26,10 @@ export default class PageHeader extends PureComponent { }; getBreadcrumbProps = () => { return { - routes: this.props.routes || this.context.routes, - params: this.props.params || this.context.params, - routerLocation: this.props.location || this.context.location, - breadcrumbNameMap: this.props.breadcrumbNameMap || this.context.breadcrumbNameMap, + routes: this.props.routes, + params: this.props.params, + routerLocation: this.props.location, + breadcrumbNameMap: this.props.breadcrumbNameMap, }; }; // Generated according to props diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 3e472658a10e85751ca7171e48814860000cca9c..26d7f9e2b573ed9f9da7b07608c6978d95e8bf9a 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import { Layout } from 'antd'; import DocumentTitle from 'react-document-title'; import { connect } from 'dva'; @@ -14,6 +13,7 @@ import Sidebar from '../components/Sidebar'; import logo from '../assets/logo.svg'; import Footer from './Footer'; import Header from './Header'; +import Context from './MeunContext'; const { Content } = Layout; const { AuthorizedRoute, check } = Authorized; @@ -61,11 +61,7 @@ const query = { }; class BasicLayout extends React.PureComponent { - static childContextTypes = { - location: PropTypes.object, - breadcrumbNameMap: PropTypes.object, - }; - getChildContext() { + getContext() { const { location, routerData, menuData } = this.props; return { location, @@ -165,10 +161,12 @@ class BasicLayout extends React.PureComponent { {params => ( -
- {layout} - -
+ +
+ {layout} + +
+
)}
diff --git a/src/layouts/MeunContext.js b/src/layouts/MeunContext.js new file mode 100644 index 0000000000000000000000000000000000000000..860f106868159e8d3e1bcd81297acddff826b1c0 --- /dev/null +++ b/src/layouts/MeunContext.js @@ -0,0 +1,3 @@ +import { createContext } from 'react'; + +export default createContext(); diff --git a/src/layouts/PageHeaderLayout.js b/src/layouts/PageHeaderLayout.js index 7416127958c8a0a02fa9d6429d7c17f6a333b589..c6e3f32d263a01016d6c84ec8e6224ee66396067 100644 --- a/src/layouts/PageHeaderLayout.js +++ b/src/layouts/PageHeaderLayout.js @@ -3,11 +3,16 @@ import { Link } from 'dva/router'; import PageHeader from '../components/PageHeader'; import GridContent from './GridContent'; import styles from './PageHeaderLayout.less'; +import MeunContext from './MeunContext'; export default ({ children, wrapperClassName, top, ...restProps }) => (
{top} - + + {value => { + return ; + }} + {children ? (
{children}