Skip to content

Commit b6c8c7b

Browse files
committed
Replace omit util function with object destructing
We are able to replace this hard-to-type-annotate function with an es6 rest destructing call (leveraging the `eslint` rule allowing unused vars starting with `_`)
1 parent e58ae89 commit b6c8c7b

3 files changed

Lines changed: 27 additions & 43 deletions

File tree

packages/flowtip-react-dom/__test__/omit.test.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/flowtip-react-dom/src/FlowTip.js

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import flowtip, {
1515

1616
import type {RectLike, Region, Align, Dimensions, Result} from 'flowtip-core';
1717

18-
import omit from './util/omit';
1918
import singleWarning from './util/singleWarning';
2019
import getContainingBlock from './util/getContainingBlock';
2120

@@ -32,28 +31,6 @@ const REMOVED_PROPS = [
3231
'rootAlignOffset',
3332
'hideInDisabledRegions',
3433
];
35-
36-
const FLOWTIP_PROPS = [
37-
'target',
38-
'bounds',
39-
'region',
40-
'sticky',
41-
'targetOffset',
42-
'edgeOffset',
43-
'tailOffset',
44-
'align',
45-
'topDisabled',
46-
'rightDisabled',
47-
'bottomDisabled',
48-
'leftDisabled',
49-
'constrainTop',
50-
'constrainRight',
51-
'constrainBottom',
52-
'constrainLeft',
53-
'content',
54-
'tail',
55-
];
56-
5734
// Static `flowtip` layout calculation result mock for use during initial client
5835
// side render or on server render where DOM feedback is not possible.
5936
const STATIC_RESULT: Result = {
@@ -126,6 +103,32 @@ export type Props = {
126103
children?: React.Node,
127104
};
128105

106+
const omitFlowtipProps = (props: Props) => {
107+
const {
108+
target: _target,
109+
bounds: _bounds,
110+
region: _region,
111+
sticky: _sticky,
112+
targetOffset: _targetOffset,
113+
edgeOffset: _edgeOffset,
114+
tailOffset: _tailOffset,
115+
align: _align,
116+
topDisabled: _topDisabled,
117+
rightDisabled: _rightDisabled,
118+
bottomDisabled: _bottomDisabled,
119+
leftDisabled: _leftDisabled,
120+
constrainTop: _constrainTop,
121+
constrainRight: _constrainRight,
122+
constrainBottom: _constrainBottom,
123+
constrainLeft: _constrainLeft,
124+
content: _content,
125+
tail: _tail,
126+
...rest
127+
} = props;
128+
129+
return rest;
130+
};
131+
129132
class FlowTip extends React.Component<Props, State> {
130133
static defaultProps = {
131134
bounds: null,
@@ -615,7 +618,7 @@ class FlowTip extends React.Component<Props, State> {
615618
const {children, content: Content} = this.props;
616619

617620
const contentProps = {
618-
...omit(FLOWTIP_PROPS, this.props),
621+
...omitFlowtipProps(this.props),
619622
style: this._getContentStyle(result),
620623
};
621624

packages/flowtip-react-dom/src/util/omit.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)