Skip to content
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

Adding support for rendering React component #131

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
27 changes: 20 additions & 7 deletions lib/ToastContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,25 @@ class ToastContainer extends Component {
bottom: keyboardHeight
};

let toastChildContent
// if the passed content is string then use Text to render
// other wise use view
// Passed view will have its own style.
if(typeof this.props.children === 'string'){
toastChildContent = <Text style={[
styles.textStyle,
props.textStyle,
props.textColor && {color: props.textColor}
]}>
{this.props.children}
</Text>
}else{
// passed component can have their own style.
toastChildContent = <View>
{this.props.children}
</View>
}

return (this.state.visible || this._animating) ? <View
style={[
styles.defaultStyle,
Expand Down Expand Up @@ -255,13 +274,7 @@ class ToastContainer extends Component {
pointerEvents="none"
ref={ele => this._root = ele}
>
<Text style={[
styles.textStyle,
props.textStyle,
props.textColor && {color: props.textColor}
]}>
{this.props.children}
</Text>
{toastChildContent}
</Animated.View>
</TouchableWithoutFeedback>
</View> : null;
Expand Down