From ed2ed147c7b68030c844394eb7e19557f2ebed3f Mon Sep 17 00:00:00 2001 From: Johannes Stein Date: Wed, 10 Jan 2018 23:27:35 +0000 Subject: [PATCH 1/2] Allow for custom component --- src/withCustomComponent.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/withCustomComponent.js diff --git a/src/withCustomComponent.js b/src/withCustomComponent.js new file mode 100644 index 0000000..03ca3f2 --- /dev/null +++ b/src/withCustomComponent.js @@ -0,0 +1,19 @@ +import React, { Component } from 'react'; +import { Text } from 'react-native'; + +const withCustomComponent = (Comp) => + class extends Component { + setNativeProps = nativeProps => { + /* eslint no-underscore-dangle: 0 */ + + this._root.setNativeProps(nativeProps); + } + + render() { + const component = this.props.component || this.context.textComponent || Text; + + return ; + } + }; + +export default withCustomComponent; From 52846833d8a3987b93645df762b67d5921455182 Mon Sep 17 00:00:00 2001 From: Johannes Stein Date: Wed, 10 Jan 2018 23:35:57 +0000 Subject: [PATCH 2/2] Add prop-types --- src/withCustomComponent.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/withCustomComponent.js b/src/withCustomComponent.js index 03ca3f2..42ad41b 100644 --- a/src/withCustomComponent.js +++ b/src/withCustomComponent.js @@ -1,8 +1,13 @@ import React, { Component } from 'react'; import { Text } from 'react-native'; +import PropTypes from 'prop-types'; const withCustomComponent = (Comp) => class extends Component { + static propTypes = { + component: PropTypes.node, + } + setNativeProps = nativeProps => { /* eslint no-underscore-dangle: 0 */