Skip to content

Commit 7930dc6

Browse files
author
Luke Brandon Farrell
authored
Merge pull request #1 from aikewoody/master
Support using custom elements as key components.
2 parents ef1ac2b + 73cba7d commit 7930dc6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

VirtualKeyboard.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,15 @@ class VirtualKeyboard extends Component {
180180
[() => keyDown("custom"), null, () => keyDown("back")]
181181
];
182182

183-
// Decide if the element passed as the key is text
184-
const keyJsx = keyboardFuncSet[row][column] ? (
185-
<Image style={[keyImageDefaultStyle, keyImageStyle]} source={entity} />
186-
) : (
187-
<Text style={[keyTextDefaultStyle, keyTextStyle]}>{entity}</Text>
188-
);
183+
// Decide what type of element is passed as the key
184+
let keyJsx;
185+
if (React.isValidElement(entity)) {
186+
keyJsx = entity;
187+
} else if (keyboardFuncSet[row][column]) {
188+
keyJsx = <Image style={[keyImageDefaultStyle, keyImageStyle]} source={entity} />;
189+
} else {
190+
keyJsx = <Text style={[keyTextDefaultStyle, keyTextStyle]}>{entity}</Text>;
191+
}
189192

190193
// We want to block keyboard interactions if it has been disabled.
191194
if (!disabled) {

0 commit comments

Comments
 (0)