Skip to content

Commit f13256e

Browse files
committed
Fix acctidental deprecation warning
1 parent a38a396 commit f13256e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Diff for: src/reducer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const handlers = {
5555

5656
function tooltip(state = initial, action) {
5757
// Check usage of deprecated props
58-
deprecatedWarning(action.payload);
58+
deprecatedWarning(action);
5959

6060
const handler = handlers[action.type];
6161
return handler ? handler(state, action) : state;

Diff for: src/utils.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import isDOM from 'is-dom';
2+
import * as actions from './actions';
23

34
function dimension(el) {
45
const rect = el.getBoundingClientRect();
@@ -235,11 +236,16 @@ export function resolve(obj) {
235236
return names;
236237
}
237238

238-
export function deprecatedWarning(props) {
239-
if (props && props.el) {
239+
const actionTypes = Object.keys(actions).map(k => actions[k]).filter(e => typeof e === 'string');
240+
export function deprecatedWarning(action) {
241+
const { type, payload } = action;
242+
if (actionTypes.indexOf(action.type) === -1) {
243+
return; // Ignore non-related actions
244+
}
245+
if (payload && payload.el) {
240246
console.warn(`DEPRECATED: Use 'origin' instead of 'el' in props for Tooltip component or 'show' action.`);
241247
}
242-
if (props && props.el && props.origin) {
248+
if (payload && payload.el && payload.origin) {
243249
console.warn(`Do not pass both 'origin' and 'el' props at the same time.`);
244250
}
245251
}

0 commit comments

Comments
 (0)