💄 format getGutter code style

This commit is contained in:
afc163 2019-10-20 12:48:03 +08:00 committed by 偏右
parent 78a1427ec0
commit 0cadae921a

View File

@ -64,23 +64,23 @@ export default class Row extends React.Component<RowProps, RowState> {
} }
getGutter(): [number, number] { getGutter(): [number, number] {
const gutter: [number, number] = [0, 0]; const results: [number, number] = [0, 0];
const { gutter: gutter_setting } = this.props; const { gutter } = this.props;
const { screens } = this.state;
(Array.isArray(gutter_setting) ? gutter_setting : [gutter_setting, 0]).forEach((g, index) => { const normalizedGutter = Array.isArray(gutter) ? gutter : [gutter, 0];
normalizedGutter.forEach((g, index) => {
if (typeof g === 'object') { if (typeof g === 'object') {
for (let i = 0; i < responsiveArray.length; i++) { for (let i = 0; i < responsiveArray.length; i++) {
const breakpoint: Breakpoint = responsiveArray[i]; const breakpoint: Breakpoint = responsiveArray[i];
if (this.state.screens[breakpoint] && g[breakpoint] !== undefined) { if (screens[breakpoint] && g[breakpoint] !== undefined) {
gutter[index] = g[breakpoint] as number; results[index] = g[breakpoint] as number;
} }
} }
} else { } else {
gutter[index] = g as number; results[index] = g || 0;
} }
}); });
return results;
return gutter;
} }
renderRow = ({ getPrefixCls }: ConfigConsumerProps) => { renderRow = ({ getPrefixCls }: ConfigConsumerProps) => {