Skip to content

Allow for custom component #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/withCustomComponent.js
Original file line number Diff line number Diff line change
@@ -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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not fix bug #12
Remove this method.
Please add me as collaborator and I will fix that issue in separate pull request.

Copy link
Owner Author

@frostney frostney Jan 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, I probably misunderstand you on this. Feel free to work on this branch directly if you want to 🙂

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks! I will add fix later today.

}

render() {
const component = this.props.component || this.context.textComponent || Text;

return <Comp {...this.props} component={component} />;
}
};

export default withCustomComponent;