Skip to content

Commit

Permalink
Backspace and delay in development mode (#65)
Browse files Browse the repository at this point in the history
* Fix the ability to use Backspace and Delay functionality when running in development mode

* Bump package patch version

* Revert version in package.json
  • Loading branch information
yjimk authored and xpertgru committed May 17, 2019
1 parent 5b29a3e commit 9c992f8
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React from 'react';
import React from "react";
import Backspace from "./Backspace";
import Delay from "./Delay";

export const sleep = (val) => new Promise((resolve) => (
val != null ? setTimeout(resolve, val) : resolve()
Expand Down Expand Up @@ -31,12 +33,25 @@ export function exclude(obj, keys) {
return res;
}

export function isElementType(element, component, name) {
const elementType = element && element.type;
if (!elementType) {
return false;
}

return (
elementType === component ||
elementType.componentName === name ||
elementType.displayName === name
);
}

export function isBackspaceElement(element) {
return element && element.type && element.type.componentName === 'Backspace';
return isElementType(element, Backspace, "Backspace");
}

export function isDelayElement(element) {
return element && element.type && element.type.componentName === 'Delay';
return isElementType(element, Delay, "Delay");
}

export function extractTextFromElement(element) {
Expand Down

0 comments on commit 9c992f8

Please sign in to comment.