Skip to content

Commit 7dcdd3e

Browse files
authored
Merge pull request #42 from nol13/master
Allow element to be passed instead of text
2 parents 72fb3e5 + cadcbfe commit 7dcdd3e

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
@@ -68,6 +68,12 @@ show a toast, and execute callback function when toast close it:
6868
Show a toast forever until you manually close it:
6969
```javascript
7070
this.refs.toast.show('hello world!', DURATION.FOREVER);
71+
```
72+
73+
Or pass an element:
74+
```javascript
75+
this.refs.toast.show(<View><Text>hello world!</Text></View>);
76+
```
7177

7278
// later on:
7379
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
@@ -111,7 +111,7 @@ export default class Toast extends Component {
111111
<Animated.View
112112
style={[styles.content, { opacity: this.state.opacityValue }, this.props.style]}
113113
>
114-
<Text style={this.props.textStyle}>{this.state.text}</Text>
114+
{React.isValidElement(this.state.text) ? this.state.text : <Text style={this.props.textStyle}>{this.state.text}</Text>}
115115
</Animated.View>
116116
</View> : null;
117117
return view;

0 commit comments

Comments
 (0)