From ea193cbdadbdaa6593372c7908e8afb2c6fb88c9 Mon Sep 17 00:00:00 2001 From: Artur Yorsh Date: Thu, 20 Sep 2018 12:20:28 +0300 Subject: [PATCH] feat(component): add prop-types validation non-validated components. Closes #93 * feat(rkText): add prop-types validation * feat(rkAvoidKeyboard): add prop-types validation --- src/components/avoidKeyboard/rkAvoidKeyboard.js | 4 ++++ src/components/text/rkText.js | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/avoidKeyboard/rkAvoidKeyboard.js b/src/components/avoidKeyboard/rkAvoidKeyboard.js index 823aef58c..74f624dab 100644 --- a/src/components/avoidKeyboard/rkAvoidKeyboard.js +++ b/src/components/avoidKeyboard/rkAvoidKeyboard.js @@ -3,6 +3,7 @@ import { Animated, Platform, Keyboard, + ViewPropTypes, } from 'react-native'; import { RkComponent } from '../rkComponent'; @@ -24,6 +25,9 @@ import { RkComponent } from '../rkComponent'; * ``` */ export class RkAvoidKeyboard extends RkComponent { + static propTypes = { + ...ViewPropTypes, + }; componentName = 'RkAvoidKeyboard'; typeMapping = { container: {}, diff --git a/src/components/text/rkText.js b/src/components/text/rkText.js index c7692a00e..3bfdda61d 100644 --- a/src/components/text/rkText.js +++ b/src/components/text/rkText.js @@ -66,6 +66,13 @@ import { RkComponent } from '../rkComponent'; */ export class RkText extends RkComponent { + static propTypes = { + rkType: RkComponent.propTypes.rkType, + ...Text.propTypes, + }; + static defaultProps = { + rkType: RkComponent.defaultProps.rkType, + }; componentName = 'RkText'; typeMapping = { text: {}, @@ -73,13 +80,14 @@ export class RkText extends RkComponent { render() { const { + rkType, style, children, ...textProps } = this.props; - const styles = this.defineStyles(); + const styles = this.defineStyles(rkType); return ( - {children} + {children} ); } }