diff --git a/components/layout/Sider.tsx b/components/layout/Sider.tsx index b08f5188fb..b81e6eb339 100644 --- a/components/layout/Sider.tsx +++ b/components/layout/Sider.tsx @@ -17,6 +17,7 @@ if (typeof window !== 'undefined') { import React from 'react'; import classNames from 'classnames'; import omit from 'omit.js'; +import PropTypes from 'prop-types'; import Icon from '../icon'; const dimensionMap = { @@ -55,6 +56,10 @@ export default class Sider extends React.Component { style: {}, }; + static childContextTypes = { + siderCollapsed: PropTypes.bool, + }; + private mql: any; constructor(props) { @@ -78,6 +83,12 @@ export default class Sider extends React.Component { }; } + getChildContext() { + return { + siderCollapsed: this.props.collapsed, + }; + } + componentWillReceiveProps(nextProps) { if ('collapsed' in nextProps) { this.setState({ diff --git a/components/layout/__tests__/__snapshots__/demo.test.js.snap b/components/layout/__tests__/__snapshots__/demo.test.js.snap index 09746263f5..b2e4e75bf8 100644 --- a/components/layout/__tests__/__snapshots__/demo.test.js.snap +++ b/components/layout/__tests__/__snapshots__/demo.test.js.snap @@ -139,7 +139,7 @@ exports[`renders ./components/layout/demo/custom-trigger.md correctly 1`] = ` />