Skip to content

Commit 066d32f

Browse files
dastoorijstejada
authored andcommitted
Use a static property to detect Backspace and Delay elements (#42)
1 parent d5ef914 commit 066d32f

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/Backspace.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
33

44
const Backspace = () => <noscript />;
55

6+
Backspace.componentName = 'Backspace';
7+
68
Backspace.propTypes = {
79
count: PropTypes.number,
810
delay: PropTypes.number,

src/Delay.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
33

44
const Delay = () => <noscript />;
55

6+
Delay.componentName = 'Delay';
7+
68
Delay.propTypes = {
79
ms: PropTypes.number.isRequired,
810
};

src/utils.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import React from 'react';
2-
import Backspace from './Backspace';
3-
import Delay from './Delay';
42

53
export const sleep = (val) => new Promise((resolve) => (
64
val != null ? setTimeout(resolve, val) : resolve()
@@ -34,11 +32,11 @@ export function exclude(obj, keys) {
3432
}
3533

3634
export function isBackspaceElement(element) {
37-
return element && element.type === Backspace;
35+
return element && element.type && element.type.componentName === 'Backspace';
3836
}
3937

4038
export function isDelayElement(element) {
41-
return element && element.type === Delay;
39+
return element && element.type && element.type.componentName === 'Delay';
4240
}
4341

4442
export function extractTextFromElement(element) {

0 commit comments

Comments
 (0)