From d1b424df1cbdd77fdc58f402d9f32b4771eb29f7 Mon Sep 17 00:00:00 2001 From: yoyo837 Date: Mon, 25 Jun 2018 15:50:56 +0800 Subject: [PATCH] fix some other eslint error , close #1722 --- src/components/Charts/Bar/index.js | 16 +++--- src/components/Charts/Pie/index.js | 63 ++++++++++++++---------- src/components/Charts/Radar/index.js | 3 +- src/components/Charts/TagCloud/index.js | 3 +- src/components/CountDown/index.js | 11 +++-- src/components/EditableItem/index.js | 17 ++++--- src/components/Ellipsis/index.js | 3 +- src/components/HeaderSearch/index.js | 46 ++++++++++------- src/components/Login/LoginItem.js | 14 ++++-- src/components/Login/LoginTab.js | 5 +- src/components/Login/index.js | 29 ++++++----- src/components/NoticeIcon/index.js | 11 +++-- src/components/PageHeader/index.js | 26 +++++++--- src/components/SiderMenu/SiderMenu.js | 15 +++--- src/components/SiderMenu/index.js | 12 +++-- src/components/StandardTable/index.js | 11 +++-- src/components/TagSelect/index.js | 17 ++++--- src/layouts/BasicLayout.js | 22 ++++++--- src/routes/Dashboard/Analysis.js | 13 +++-- src/routes/Dashboard/Monitor.js | 3 +- src/routes/Exception/triggerException.js | 6 ++- src/routes/Forms/AdvancedForm.js | 6 ++- src/routes/Forms/BasicForm.js | 9 ++-- src/routes/Forms/TableForm.js | 50 ++++++++++++------- src/routes/List/Applications.js | 3 +- src/routes/List/Articles.js | 3 +- src/routes/List/BasicList.js | 3 +- src/routes/List/CardList.js | 3 +- src/routes/List/Projects.js | 3 +- src/routes/List/TableList.js | 15 ++++-- src/routes/Profile/AdvancedProfile.js | 4 +- src/routes/User/Login.js | 7 +-- src/routes/User/Register.js | 27 +++++----- 33 files changed, 292 insertions(+), 187 deletions(-) diff --git a/src/components/Charts/Bar/index.js b/src/components/Charts/Bar/index.js index a3c36084..87b4a8a1 100644 --- a/src/components/Charts/Bar/index.js +++ b/src/components/Charts/Bar/index.js @@ -19,6 +19,14 @@ class Bar extends Component { window.removeEventListener('resize', this.resize); } + handleRoot = n => { + this.root = n; + }; + + handleRef = n => { + this.node = n; + }; + @Bind() @Debounce(400) resize() { @@ -46,14 +54,6 @@ class Bar extends Component { } } - handleRoot = n => { - this.root = n; - }; - - handleRef = n => { - this.node = n; - }; - render() { const { height, diff --git a/src/components/Charts/Pie/index.js b/src/components/Charts/Pie/index.js index 0d0dc3c5..a0301723 100644 --- a/src/components/Charts/Pie/index.js +++ b/src/components/Charts/Pie/index.js @@ -25,12 +25,14 @@ export default class Pie extends Component { } componentWillReceiveProps(nextProps) { - if (this.props.data !== nextProps.data) { + const { data } = this.props; + if (data !== nextProps.data) { // because of charts data create when rendered // so there is a trick for get rendered time + const { legendData } = this.state; this.setState( { - legendData: [...this.state.legendData], + legendData: [...legendData], }, () => { this.getLegendData(); @@ -67,28 +69,6 @@ export default class Pie extends Component { }); }; - // for window resize auto responsive legend - @Bind() - @Debounce(300) - resize() { - const { hasLegend } = this.props; - if (!hasLegend || !this.root) { - window.removeEventListener('resize', this.resize); - return; - } - if (this.root.parentNode.clientWidth <= 380) { - if (!this.state.legendBlock) { - this.setState({ - legendBlock: true, - }); - } - } else if (this.state.legendBlock) { - this.setState({ - legendBlock: false, - }); - } - } - handleRoot = n => { this.root = n; }; @@ -111,6 +91,29 @@ export default class Pie extends Component { }); }; + // for window resize auto responsive legend + @Bind() + @Debounce(300) + resize() { + const { hasLegend } = this.props; + if (!hasLegend || !this.root) { + window.removeEventListener('resize', this.resize); + return; + } + const { legendBlock } = this.state; + if (this.root.parentNode.clientWidth <= 380) { + if (!legendBlock) { + this.setState({ + legendBlock: true, + }); + } + } else if (legendBlock) { + this.setState({ + legendBlock: false, + }); + } + } + render() { const { valueFormat, @@ -135,10 +138,16 @@ export default class Pie extends Component { [styles.legendBlock]: legendBlock, }); + const { data: d, selected: s, tooltip: t } = this.props; + + let data = d || []; + let selected = s || true; + let tooltip = t || true; + const defaultColors = colors; - let data = this.props.data || []; - let selected = this.props.selected || true; - let tooltip = this.props.tooltip || true; + // let data = this.props.data || []; + // let selected = this.props.selected || true; + // let tooltip = this.props.tooltip || true; let formatColor; const scale = { diff --git a/src/components/Charts/Radar/index.js b/src/components/Charts/Radar/index.js index fc3ab444..c6203a7b 100644 --- a/src/components/Charts/Radar/index.js +++ b/src/components/Charts/Radar/index.js @@ -16,7 +16,8 @@ export default class Radar extends Component { } componentWillReceiveProps(nextProps) { - if (this.props.data !== nextProps.data) { + const { data } = this.props; + if (data !== nextProps.data) { this.getLengendData(); } } diff --git a/src/components/Charts/TagCloud/index.js b/src/components/Charts/TagCloud/index.js index 08418ea1..22af3838 100644 --- a/src/components/Charts/TagCloud/index.js +++ b/src/components/Charts/TagCloud/index.js @@ -25,7 +25,8 @@ class TagCloud extends Component { } componentWillReceiveProps(nextProps) { - if (JSON.stringify(nextProps.data) !== JSON.stringify(this.props.data)) { + const { data } = this.props; + if (JSON.stringify(nextProps.data) !== JSON.stringify(data)) { this.renderChart(nextProps); } } diff --git a/src/components/CountDown/index.js b/src/components/CountDown/index.js index b67fab2f..15e3cc48 100644 --- a/src/components/CountDown/index.js +++ b/src/components/CountDown/index.js @@ -5,6 +5,10 @@ function fixedZero(val) { } class CountDown extends Component { + timer = 0; + + interval = 1000; + constructor(props) { super(props); @@ -20,7 +24,8 @@ class CountDown extends Component { } componentWillReceiveProps(nextProps) { - if (this.props.target !== nextProps.target) { + const { target } = this.props; + if (target !== nextProps.target) { clearTimeout(this.timer); const { lastTime } = this.initTime(nextProps); this.setState( @@ -38,10 +43,6 @@ class CountDown extends Component { clearTimeout(this.timer); } - timer = 0; - - interval = 1000; - initTime = props => { let lastTime = 0; let targetTime = 0; diff --git a/src/components/EditableItem/index.js b/src/components/EditableItem/index.js index 5b22631c..272b7114 100644 --- a/src/components/EditableItem/index.js +++ b/src/components/EditableItem/index.js @@ -3,10 +3,13 @@ import { Input, Icon } from 'antd'; import styles from './index.less'; export default class EditableItem extends PureComponent { - state = { - value: this.props.value, - editable: false, - }; + constructor(props) { + super(props); + this.state = { + value: props.value, + editable: false, + }; + } handleChange = e => { const { value } = e.target; @@ -15,8 +18,10 @@ export default class EditableItem extends PureComponent { check = () => { this.setState({ editable: false }); - if (this.props.onChange) { - this.props.onChange(this.state.value); + const { onChange } = this.props; + const { value } = this.state; + if (onChange) { + onChange(value); } }; diff --git a/src/components/Ellipsis/index.js b/src/components/Ellipsis/index.js index 8306b5d8..8cae96a5 100644 --- a/src/components/Ellipsis/index.js +++ b/src/components/Ellipsis/index.js @@ -84,7 +84,8 @@ export default class Ellipsis extends Component { } componentWillReceiveProps(nextProps) { - if (this.props.lines !== nextProps.lines) { + const { lines } = this.props; + if (lines !== nextProps.lines) { this.computeLine(); } } diff --git a/src/components/HeaderSearch/index.js b/src/components/HeaderSearch/index.js index de8a6be5..b67901fc 100644 --- a/src/components/HeaderSearch/index.js +++ b/src/components/HeaderSearch/index.js @@ -27,10 +27,13 @@ export default class HeaderSearch extends PureComponent { defaultOpen: false, }; - state = { - searchMode: this.props.defaultOpen, - value: '', - }; + constructor(props) { + super(props); + this.state = { + searchMode: props.defaultOpen, + value: '', + }; + } onKeyDown = e => { if (e.key === 'Enter') { @@ -40,24 +43,16 @@ export default class HeaderSearch extends PureComponent { onChange = value => { this.setState({ value }); - if (this.props.onChange) { - this.props.onChange(); + const { onChange } = this.props; + if (onChange) { + onChange(); } }; - // NOTE: 不能小于500,如果长按某键,第一次触发auto repeat的间隔是500ms,小于500会导致触发2次 - @Bind() - @Debounce(500, { - leading: true, - trailing: false, - }) - debouncePressEnter() { - this.props.onPressEnter(this.state.value); - } - enterSearchMode = () => { this.setState({ searchMode: true }, () => { - if (this.state.searchMode) { + const { searchMode } = this.state; + if (searchMode) { this.input.focus(); } }); @@ -70,11 +65,24 @@ export default class HeaderSearch extends PureComponent { }); }; + debouncePressEnter() { + const { onPressEnter } = this.props; + const { value } = this.state; + onPressEnter(value); + } + + // NOTE: 不能小于500,如果长按某键,第一次触发auto repeat的间隔是500ms,小于500会导致触发2次 + @Bind() + @Debounce(500, { + leading: true, + trailing: false, + }) render() { const { className, placeholder, ...restProps } = this.props; + const { searchMode, value } = this.state; delete restProps.defaultOpen; // for rc-select not affected const inputClass = classNames(styles.input, { - [styles.show]: this.state.searchMode, + [styles.show]: searchMode, }); return ( @@ -83,7 +91,7 @@ export default class HeaderSearch extends PureComponent { key="AutoComplete" {...restProps} className={inputClass} - value={this.state.value} + value={value} onChange={this.onChange} > { let count = 59; this.setState({ count }); - if (this.props.onGetCaptcha) { - this.props.onGetCaptcha(); + const { onGetCaptcha } = this.props; + if (onGetCaptcha) { + onGetCaptcha(); } this.interval = setInterval(() => { count -= 1; @@ -48,7 +51,8 @@ function generator({ defaultProps, defaultRules, type }) { }; render() { - const { getFieldDecorator } = this.context.form; + const { form } = this.context; + const { getFieldDecorator } = form; const options = {}; let otherProps = {}; const { onChange, defaultValue, rules, name, ...restProps } = this.props; diff --git a/src/components/Login/LoginTab.js b/src/components/Login/LoginTab.js index 52de12d2..73c9d7c9 100644 --- a/src/components/Login/LoginTab.js +++ b/src/components/Login/LoginTab.js @@ -25,8 +25,9 @@ export default class LoginTab extends Component { } componentWillMount() { - if (this.context.tabUtil) { - this.context.tabUtil.addTab(this.uniqueId); + const { tabUtil } = this.context; + if (tabUtil) { + tabUtil.addTab(this.uniqueId); } } diff --git a/src/components/Login/index.js b/src/components/Login/index.js index 31235017..5f5d7d5c 100644 --- a/src/components/Login/index.js +++ b/src/components/Login/index.js @@ -28,27 +28,32 @@ class Login extends Component { onSubmit: () => {}, }; - state = { - type: this.props.defaultActiveKey, - tabs: [], - active: {}, - }; + constructor(props) { + super(props); + this.state = { + type: props.defaultActiveKey, + tabs: [], + active: {}, + }; + } getChildContext() { + const { tabs } = this.state; + const { form } = this.props; return { tabUtil: { addTab: id => { this.setState({ - tabs: [...this.state.tabs, id], + tabs: [...tabs, id], }); }, removeTab: id => { this.setState({ - tabs: this.state.tabs.filter(currentId => currentId !== id), + tabs: tabs.filter(currentId => currentId !== id), }); }, }, - form: this.props.form, + form, updateActive: activeItem => { const { type, active } = this.state; if (active[type]) { @@ -64,18 +69,20 @@ class Login extends Component { } onSwitch = type => { + const { onTabChange } = this.props; this.setState({ type, }); - this.props.onTabChange(type); + onTabChange(type); }; handleSubmit = e => { e.preventDefault(); const { active, type } = this.state; + const { form, onSubmit } = this.props; const activeFileds = active[type]; - this.props.form.validateFields(activeFileds, { force: true }, (err, values) => { - this.props.onSubmit(err, values); + form.validateFields(activeFileds, { force: true }, (err, values) => { + onSubmit(err, values); }); }; diff --git a/src/components/NoticeIcon/index.js b/src/components/NoticeIcon/index.js index 5561f0ef..3ea8213e 100644 --- a/src/components/NoticeIcon/index.js +++ b/src/components/NoticeIcon/index.js @@ -37,11 +37,12 @@ export default class NoticeIcon extends PureComponent { onTabChange = tabType => { this.setState({ tabType }); - this.props.onTabChange(tabType); + const { onTabChange } = this.state; + onTabChange(tabType); }; getNotificationBox() { - const { children, loading, locale } = this.props; + const { children, loading, locale, onClear } = this.props; if (!children) { return null; } @@ -56,7 +57,7 @@ export default class NoticeIcon extends PureComponent { {...child.props} data={child.props.list} onClick={item => this.onItemClick(item, child.props)} - onClear={() => this.props.onClear(child.props.title)} + onClear={() => onClear(child.props.title)} title={child.props.title} locale={locale} /> @@ -73,7 +74,7 @@ export default class NoticeIcon extends PureComponent { } render() { - const { className, count, popupAlign, onPopupVisibleChange } = this.props; + const { className, count, popupAlign, onPopupVisibleChange, popupVisible } = this.props; const noticeButtonClass = classNames(className, styles.noticeButton); const notificationBox = this.getNotificationBox(); const trigger = ( @@ -88,7 +89,7 @@ export default class NoticeIcon extends PureComponent { } const popoverProps = {}; if ('popupVisible' in this.props) { - popoverProps.visible = this.props.popupVisible; + popoverProps.visible = popupVisible; } return ( { - if (this.props.onTabChange) { - this.props.onTabChange(key); + const { onTabChange } = this.props; + if (onTabChange) { + onTabChange(key); } }; getBreadcrumbProps = () => { + const { routes, params, location, breadcrumbNameMap } = this.props; + const { + routes: croutes, + params: cparams, + location: clocation, + breadcrumbNameMap: cbreadcrumbNameMap, + } = this.context; 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: routes || croutes, + params: params || cparams, + routerLocation: location || clocation, + breadcrumbNameMap: breadcrumbNameMap || cbreadcrumbNameMap, }; }; @@ -185,6 +194,7 @@ export default class PageHeader extends PureComponent { tabDefaultActiveKey, tabBarExtraContent, } = this.props; + const { breadcrumb } = this.state; const clsString = classNames(styles.pageHeader, className); const activeKeyProps = {}; @@ -197,7 +207,7 @@ export default class PageHeader extends PureComponent { return (
- {this.state.breadcrumb} + {breadcrumb}
{logo &&
{logo}
}
diff --git a/src/components/SiderMenu/SiderMenu.js b/src/components/SiderMenu/SiderMenu.js index fc93fca8..aab2aaff 100644 --- a/src/components/SiderMenu/SiderMenu.js +++ b/src/components/SiderMenu/SiderMenu.js @@ -59,7 +59,8 @@ export default class SiderMenu extends PureComponent { } componentWillReceiveProps(nextProps) { - if (nextProps.location.pathname !== this.props.location.pathname) { + const { location } = this.props; + if (nextProps.location.pathname !== location.pathname) { this.setState({ openKeys: this.getDefaultCollapsedSubMenus(nextProps), }); @@ -97,15 +98,16 @@ export default class SiderMenu extends PureComponent { ); } + const { location, isMobile, onCollapse } = this.props; return ( { - this.props.onCollapse(true); + onCollapse(true); } : undefined } @@ -186,8 +188,9 @@ export default class SiderMenu extends PureComponent { // permission to check checkPermissionItem = (authority, ItemDom) => { - if (this.props.Authorized && this.props.Authorized.check) { - const { check } = this.props.Authorized; + const { Authorized } = this.props; + if (Authorized && Authorized.check) { + const { check } = Authorized; return check(authority, ItemDom); } return ItemDom; diff --git a/src/components/SiderMenu/index.js b/src/components/SiderMenu/index.js index a23459d5..e1f060cf 100644 --- a/src/components/SiderMenu/index.js +++ b/src/components/SiderMenu/index.js @@ -3,24 +3,26 @@ import React from 'react'; import DrawerMenu from 'rc-drawer'; import SiderMenu from './SiderMenu'; -const SiderMenuWrapper = props => - props.isMobile ? ( +const SiderMenuWrapper = props => { + const { isMobile, collapsed } = props; + return isMobile ? ( } onHandleClick={() => { - props.onCollapse(!props.collapsed); + props.onCollapse(!collapsed); }} - open={!props.collapsed} + open={!collapsed} onMaskClick={() => { props.onCollapse(true); }} > - + ) : ( ); +}; export default SiderMenuWrapper; diff --git a/src/components/StandardTable/index.js b/src/components/StandardTable/index.js index ea255cf8..c315346e 100644 --- a/src/components/StandardTable/index.js +++ b/src/components/StandardTable/index.js @@ -36,7 +36,9 @@ class StandardTable extends PureComponent { } handleRowSelectChange = (selectedRowKeys, selectedRows) => { - let needTotalList = [...this.state.needTotalList]; + const { needTotalList: list } = this.state; + const { onSelectRow } = this.props; + let needTotalList = [...list]; needTotalList = needTotalList.map(item => { return { ...item, @@ -46,15 +48,16 @@ class StandardTable extends PureComponent { }; }); - if (this.props.onSelectRow) { - this.props.onSelectRow(selectedRows); + if (onSelectRow) { + onSelectRow(selectedRows); } this.setState({ selectedRowKeys, needTotalList }); }; handleTableChange = (pagination, filters, sorter) => { - this.props.onChange(pagination, filters, sorter); + const { onChange } = this.props; + onChange(pagination, filters, sorter); }; cleanSelectedKeys = () => { diff --git a/src/components/TagSelect/index.js b/src/components/TagSelect/index.js index d86425c1..ffdd3eea 100644 --- a/src/components/TagSelect/index.js +++ b/src/components/TagSelect/index.js @@ -15,10 +15,13 @@ const TagSelectOption = ({ children, checked, onChange, value }) => ( TagSelectOption.isTagSelectOption = true; class TagSelect extends Component { - state = { - expand: false, - value: this.props.value || this.props.defaultValue || [], - }; + constructor(props) { + super(props); + this.state = { + expand: false, + value: props.value || props.defaultValue || [], + }; + } componentWillReceiveProps(nextProps) { if ('value' in nextProps && nextProps.value) { @@ -54,7 +57,8 @@ class TagSelect extends Component { } handleTagChange = (value, checked) => { - const checkedTags = [...this.state.value]; + const { value: v } = this.state; + const checkedTags = [...v]; const index = checkedTags.indexOf(value); if (checked && index === -1) { @@ -66,8 +70,9 @@ class TagSelect extends Component { }; handleExpand = () => { + const { expand } = this.state; this.setState({ - expand: !this.state.expand, + expand: !expand, }); }; diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index a6350edf..a78235b5 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -108,7 +108,8 @@ class BasicLayout extends React.PureComponent { isMobile: mobile, }); }); - this.props.dispatch({ + const { dispatch } = this.props; + dispatch({ type: 'user/fetchCurrent', }); } @@ -156,7 +157,8 @@ class BasicLayout extends React.PureComponent { }; handleMenuCollapse = collapsed => { - this.props.dispatch({ + const { dispatch } = this.props; + dispatch({ type: 'global/changeLayoutCollapsed', payload: collapsed, }); @@ -164,27 +166,30 @@ class BasicLayout extends React.PureComponent { handleNoticeClear = type => { message.success(`清空了${type}`); - this.props.dispatch({ + const { dispatch } = this.props; + dispatch({ type: 'global/clearNotices', payload: type, }); }; handleMenuClick = ({ key }) => { + const { dispatch } = this.props; if (key === 'triggerError') { - this.props.dispatch(routerRedux.push('/exception/trigger')); + dispatch(routerRedux.push('/exception/trigger')); return; } if (key === 'logout') { - this.props.dispatch({ + dispatch({ type: 'login/logout', }); } }; handleNoticeVisibleChange = visible => { + const { dispatch } = this.props; if (visible) { - this.props.dispatch({ + dispatch({ type: 'global/fetchNotices', }); } @@ -200,6 +205,7 @@ class BasicLayout extends React.PureComponent { match, location, } = this.props; + const { isMobile: mb } = this.state; const bashRedirect = this.getBaseRedirect(); const layout = ( @@ -212,7 +218,7 @@ class BasicLayout extends React.PureComponent { menuData={getMenuData()} collapsed={collapsed} location={location} - isMobile={this.state.isMobile} + isMobile={mb} onCollapse={this.handleMenuCollapse} /> @@ -223,7 +229,7 @@ class BasicLayout extends React.PureComponent { fetchingNotices={fetchingNotices} notices={notices} collapsed={collapsed} - isMobile={this.state.isMobile} + isMobile={mb} onNoticeClear={this.handleNoticeClear} onCollapse={this.handleMenuCollapse} onMenuClick={this.handleMenuClick} diff --git a/src/routes/Dashboard/Analysis.js b/src/routes/Dashboard/Analysis.js index 61704899..6ffb6df7 100644 --- a/src/routes/Dashboard/Analysis.js +++ b/src/routes/Dashboard/Analysis.js @@ -44,8 +44,8 @@ for (let i = 0; i < 7; i += 1) { const Yuan = ({ children }) => ( /* eslint-disable-line react/no-danger */ + dangerouslySetInnerHTML={{ __html: yuan(children) }} /* eslint-disable-line react/no-danger */ + /> ); @connect(({ chart, loading }) => ({ @@ -60,7 +60,8 @@ export default class Analysis extends Component { }; componentDidMount() { - this.props.dispatch({ + const { dispatch } = this.props; + dispatch({ type: 'chart/fetch', }); } @@ -89,7 +90,8 @@ export default class Analysis extends Component { rangePickerValue, }); - this.props.dispatch({ + const { dispatch } = this.props; + dispatch({ type: 'chart/fetchSalesData', }); }; @@ -99,7 +101,8 @@ export default class Analysis extends Component { rangePickerValue: getTimeDistance(type), }); - this.props.dispatch({ + const { dispatch } = this.props; + dispatch({ type: 'chart/fetchSalesData', }); }; diff --git a/src/routes/Dashboard/Monitor.js b/src/routes/Dashboard/Monitor.js index 96fbfed0..6d56a941 100644 --- a/src/routes/Dashboard/Monitor.js +++ b/src/routes/Dashboard/Monitor.js @@ -25,7 +25,8 @@ const havePermissionAsync = new Promise(resolve => { })) export default class Monitor extends PureComponent { componentDidMount() { - this.props.dispatch({ + const { dispatch } = this.props; + dispatch({ type: 'monitor/fetchTags', }); } diff --git a/src/routes/Exception/triggerException.js b/src/routes/Exception/triggerException.js index 4699d458..3daab286 100644 --- a/src/routes/Exception/triggerException.js +++ b/src/routes/Exception/triggerException.js @@ -15,7 +15,8 @@ export default class TriggerException extends PureComponent { this.setState({ isloading: true, }); - this.props.dispatch({ + const { dispatch } = this.props; + dispatch({ type: 'error/query', payload: { code, @@ -24,9 +25,10 @@ export default class TriggerException extends PureComponent { }; render() { + const { isloading } = this.state; return ( - + diff --git a/src/routes/Forms/AdvancedForm.js b/src/routes/Forms/AdvancedForm.js index 741a37b1..63faa644 100644 --- a/src/routes/Forms/AdvancedForm.js +++ b/src/routes/Forms/AdvancedForm.js @@ -73,12 +73,14 @@ class AdvancedForm extends PureComponent { resizeFooterToolbar = () => { const sider = document.querySelectorAll('.ant-layout-sider')[0]; const width = `calc(100% - ${sider.style.width})`; - if (this.state.width !== width) { + const { width: w } = this.state; + if (w !== width) { this.setState({ width }); } }; render() { + const { width: w } = this.state; const { form, dispatch, submitting } = this.props; const { getFieldDecorator, validateFieldsAndScroll, getFieldsError } = form; const validate = () => { @@ -287,7 +289,7 @@ class AdvancedForm extends PureComponent { initialValue: tableData, })()} - + {getErrorInfo()}