diff --git a/src/withCustomComponent.js b/src/withCustomComponent.js new file mode 100644 index 0000000..42ad41b --- /dev/null +++ b/src/withCustomComponent.js @@ -0,0 +1,24 @@ +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 */ + + this._root.setNativeProps(nativeProps); + } + + render() { + const component = this.props.component || this.context.textComponent || Text; + + return ; + } + }; + +export default withCustomComponent;