Skip to content

Commit cadcbfe

Browse files
author
nolan
committed
allow element to be passed instead of text
1 parent 6fd5a5f commit cadcbfe

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ That's it, you're ready to go!
6060
Show a toast forever until you manually close it:
6161
```javascript
6262
this.refs.toast.show('hello world!', DURATION.FOREVER);
63+
```
64+
65+
Or pass an element:
66+
```javascript
67+
this.refs.toast.show(<View><Text>hello world!</Text></View>);
68+
```
6369

6470
// later on:
6571
this.refs.toast.close('hello world!');

README.zh.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464

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

67+
或者像这样
68+
```javascript
69+
this.refs.toast.show(<View><Text>hello world!</Text></View>);
70+
```
6771

6872

6973
### 用例

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default class Toast extends Component {
108108
<Animated.View
109109
style={[styles.content, { opacity: this.state.opacityValue }, this.props.style]}
110110
>
111-
<Text style={this.props.textStyle}>{this.state.text}</Text>
111+
{React.isValidElement(this.state.text) ? this.state.text : <Text style={this.props.textStyle}>{this.state.text}</Text>}
112112
</Animated.View>
113113
</View> : null;
114114
return view;

0 commit comments

Comments
 (0)