Skip to content

Commit

Permalink
Merge pull request #42 from nol13/master
Browse files Browse the repository at this point in the history
Allow element to be passed instead of text
  • Loading branch information
crazycodeboy authored Mar 13, 2018
2 parents 72fb3e5 + cadcbfe commit 7dcdd3e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ show a toast, and execute callback function when toast close it:
Show a toast forever until you manually close it:
```javascript
this.refs.toast.show('hello world!', DURATION.FOREVER);
```

Or pass an element:
```javascript
this.refs.toast.show(<View><Text>hello world!</Text></View>);
```

// later on:
this.refs.toast.close('hello world!');
Expand Down
4 changes: 4 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@

在需要弹出提示框时使用上面代码即可。

或者像这样
```javascript
this.refs.toast.show(<View><Text>hello world!</Text></View>);
```


### 用例
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default class Toast extends Component {
<Animated.View
style={[styles.content, { opacity: this.state.opacityValue }, this.props.style]}
>
<Text style={this.props.textStyle}>{this.state.text}</Text>
{React.isValidElement(this.state.text) ? this.state.text : <Text style={this.props.textStyle}>{this.state.text}</Text>}
</Animated.View>
</View> : null;
return view;
Expand Down

0 comments on commit 7dcdd3e

Please sign in to comment.