Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ declare module "react-native-root-toast"{
CENTER:number,
}
export default class Toast extends React.Component<ToastProps>{
static show:(message:string,options?:ToastOptions)=>any;
static show:(message:React.ReactNode,options?:ToastOptions)=>any;
static hide:(toast:any)=>void;
static durations:Durations;
static positions:Positions;
Expand Down
26 changes: 19 additions & 7 deletions lib/ToastContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,24 @@ class ToastContainer extends Component {
bottom: keyboardHeight
};

// support element
const { children } = props

let child = children

// single element & not valid
if (React.Children.count(children) <= 1 && !React.isValidElement(children)) {
child = (
<Text style={[
styles.textStyle,
props.textStyle,
props.textColor && {color: props.textColor}
]}>
{children || ''}
</Text>
)
}

return (this.state.visible || this._animating) ? <View
style={[
styles.defaultStyle,
Expand Down Expand Up @@ -247,13 +265,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>
{child}
</Animated.View>
</TouchableWithoutFeedback>
</View> : null;
Expand Down