Skip to content

Commit

Permalink
fix: empty title, message error of rn-actionsheet, close #1767
Browse files Browse the repository at this point in the history
  • Loading branch information
silentcloud committed Aug 31, 2017
1 parent 9d2a330 commit 7810b87
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions components/action-sheet/AndroidContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class ActionSheetAndroid extends React.Component<IActionSheetNativeProps, any> {
title, message, url, options, destructiveButtonIndex, cancelButtonIndex, excludedActivityTypes,
} = config;
const titleMsg = share ? (
url && <View style={styles.title} key="0"><Text>{url}</Text></View>
!!url && <View style={styles.title} key="0"><Text>{url}</Text></View>
) : (
title && <View style={styles.title} key="0"><Text style={styles.titleText}>{title}</Text></View>
!!title && <View style={styles.title} key="0"><Text style={styles.titleText}>{title}</Text></View>
);
const content = share ? (
excludedActivityTypes.map((item, index) => <View key={index}>{item}</View>)
Expand Down Expand Up @@ -75,7 +75,7 @@ class ActionSheetAndroid extends React.Component<IActionSheetNativeProps, any> {
>
<View>
{titleMsg}
{message && <View style={styles.message} key="1"><Text>{message}</Text></View>}
{!!message && <View style={styles.message} key="1"><Text>{message}</Text></View>}
<View>{content}</View>
</View>
</Modal>
Expand Down

6 comments on commit 7810b87

@paranoidjk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没看懂,为啥要强转了boolean?

@silentcloud
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paranoidjk 排除空字符串

@paranoidjk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RN 允许 <View>false</View> ?

@silentcloud
Copy link
Contributor Author

@silentcloud silentcloud commented on 7810b87 Aug 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前面只是个判断,放在 dom 里之后就不是 boolean 值了

@paranoidjk
Copy link
Contributor

@paranoidjk paranoidjk commented on 7810b87 Aug 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我理解是这样

var a = '';
var b = 'b';

assert((a && b) === a)
assert((!!a && b) === false)

@silentcloud
Copy link
Contributor Author

@silentcloud silentcloud commented on 7810b87 Aug 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paranoidjk react 里是不一样的,(!!a && b) 是 dom,你把 b 设置成 dom 试

描述有误,应该是 解析后是 {false} 放在 react dom 里渲染不会有影响,

Please sign in to comment.