[CHORE] Use React Fragment shorthand (#1212)

This commit is contained in:
vitorandos 2019-09-24 17:26:56 -03:00 committed by Diego Mello
parent 319ca7f044
commit 94346634ae
20 changed files with 60 additions and 60 deletions

View File

@ -10,10 +10,10 @@ const RightButtons = React.memo(({
return <SendButton onPress={submit} />;
}
return (
<React.Fragment>
<>
<AudioButton onPress={recordAudioMessage} />
<FileButton onPress={showFileActions} />
</React.Fragment>
</>
);
});

View File

@ -168,7 +168,7 @@ export default class Audio extends React.Component {
}
return (
<React.Fragment>
<>
<View style={styles.audioContainer}>
<Video
ref={this.setRef}
@ -196,7 +196,7 @@ export default class Audio extends React.Component {
<Text style={styles.duration}>{this.duration}</Text>
</View>
<Markdown msg={description} baseUrl={baseUrl} username={user.username} getCustomEmoji={getCustomEmoji} useMarkdown={useMarkdown} />
</React.Fragment>
</>
);
}
}

View File

@ -21,10 +21,10 @@ const Broadcast = React.memo(({
style={styles.button}
hitSlop={BUTTON_HIT_SLOP}
>
<React.Fragment>
<>
<CustomIcon name='back' size={20} style={styles.buttonIcon} />
<Text style={styles.buttonText}>{I18n.t('Reply')}</Text>
</React.Fragment>
</>
</Touchable>
</View>
);

View File

@ -15,7 +15,7 @@ const Discussion = React.memo(({
const time = formatLastMessage(dlm);
const buttonText = formatMessageCount(dcount, DISCUSSION);
return (
<React.Fragment>
<>
<Text style={styles.startedDiscussion}>{I18n.t('Started_discussion')}</Text>
<Text style={styles.text}>{msg}</Text>
<View style={styles.buttonContainer}>
@ -25,14 +25,14 @@ const Discussion = React.memo(({
style={[styles.button, styles.smallButton]}
hitSlop={BUTTON_HIT_SLOP}
>
<React.Fragment>
<>
<CustomIcon name='chat' size={20} style={styles.buttonIcon} />
<Text style={styles.buttonText}>{buttonText}</Text>
</React.Fragment>
</>
</Touchable>
<Text style={styles.time}>{time}</Text>
</View>
</React.Fragment>
</>
);
}, (prevProps, nextProps) => {
if (prevProps.msg !== nextProps.msg) {

View File

@ -21,23 +21,23 @@ import CallButton from './CallButton';
const MessageInner = React.memo((props) => {
if (props.type === 'discussion-created') {
return (
<React.Fragment>
<>
<User {...props} />
<Discussion {...props} />
</React.Fragment>
</>
);
}
if (props.type === 'jitsi_call_started') {
return (
<React.Fragment>
<>
<User {...props} />
<Content {...props} isInfo />
<CallButton {...props} />
</React.Fragment>
</>
);
}
return (
<React.Fragment>
<>
<User {...props} />
<Content {...props} />
<Attachments {...props} />
@ -45,7 +45,7 @@ const MessageInner = React.memo((props) => {
<Thread {...props} />
<Reactions {...props} />
<Broadcast {...props} />
</React.Fragment>
</>
);
});
MessageInner.displayName = 'MessageInner';

View File

@ -89,10 +89,10 @@ const Url = React.memo(({
style={[styles.button, index > 0 && styles.marginTop, styles.container]}
background={Touchable.Ripple('#fff')}
>
<React.Fragment>
<>
<UrlImage image={url.image} user={user} baseUrl={baseUrl} />
<UrlContent title={url.title} description={url.description} />
</React.Fragment>
</>
</Touchable>
);
}, (oldProps, newProps) => isEqual(oldProps.url, newProps.url));

View File

@ -48,7 +48,7 @@ const Video = React.memo(({
};
return (
<React.Fragment>
<>
<Touchable
onPress={onPress}
style={styles.button}
@ -61,7 +61,7 @@ const Video = React.memo(({
/>
</Touchable>
<Markdown msg={file.description} baseUrl={baseUrl} username={user.username} getCustomEmoji={getCustomEmoji} useMarkdown={useMarkdown} />
</React.Fragment>
</>
);
}, (prevProps, nextProps) => isEqual(prevProps.file, nextProps.file));

View File

@ -239,11 +239,11 @@ class CustomInsideStack extends React.Component {
render() {
const { navigation } = this.props;
return (
<React.Fragment>
<>
<InsideStackModal navigation={navigation} />
<NotificationBadge navigation={navigation} />
<Toast />
</React.Fragment>
</>
);
}
}

View File

@ -200,13 +200,13 @@ class NotificationBadge extends React.Component {
hitSlop={BUTTON_HIT_SLOP}
background={Touchable.SelectableBackgroundBorderless()}
>
<React.Fragment>
<>
<Avatar text={name} size={AVATAR_SIZE} type={type} baseUrl={baseUrl} style={styles.avatar} userId={userId} token={token} />
<View>
<Text style={styles.roomName}>{name}</Text>
<Text style={[styles.message, { maxWidth: maxWidthMessage }]} numberOfLines={1}>{message}</Text>
</View>
</React.Fragment>
</>
</Touchable>
<TouchableOpacity onPress={this.hide}>
<CustomIcon name='circle-cross' style={styles.close} size={20} />

View File

@ -44,10 +44,10 @@ export const LeftActions = React.memo(({
]}
>
<RectButton style={styles.actionButton} onPress={onToggleReadPress}>
<React.Fragment>
<>
<CustomIcon size={20} name={isRead ? 'flag' : 'check'} color='white' />
<Text style={styles.actionText}>{I18n.t(isRead ? 'Unread' : 'Read')}</Text>
</React.Fragment>
</>
</RectButton>
</Animated.View>
</Animated.View>
@ -87,10 +87,10 @@ export const RightActions = React.memo(({
]}
>
<RectButton style={[styles.actionButton, { backgroundColor: '#ffbb00' }]} onPress={toggleFav}>
<React.Fragment>
<>
<CustomIcon size={20} name={favorite ? 'Star-filled' : 'star'} color='white' />
<Text style={styles.actionText}>{I18n.t(favorite ? 'Unfavorite' : 'Favorite')}</Text>
</React.Fragment>
</>
</RectButton>
</Animated.View>
<Animated.View
@ -103,10 +103,10 @@ export const RightActions = React.memo(({
]}
>
<RectButton style={[styles.actionButton, { backgroundColor: '#54585e' }]} onPress={onHidePress}>
<React.Fragment>
<>
<CustomIcon size={20} name='eye-off' color='white' />
<Text style={styles.actionText}>{I18n.t('Hide')}</Text>
</React.Fragment>
</>
</RectButton>
</Animated.View>
</View>

View File

@ -12,8 +12,8 @@ const styles = StyleSheet.create({
});
export default React.memo(() => (
<React.Fragment>
<>
<StatusBar />
{isAndroid ? <Image source={{ uri: 'launch_screen' }} style={styles.image} /> : null}
</React.Fragment>
</>
));

View File

@ -105,7 +105,7 @@ class AuthenticationWebView extends React.PureComponent {
const { loading } = this.state;
const uri = navigation.getParam('url');
return (
<React.Fragment>
<>
<StatusBar />
<WebView
useWebKit
@ -120,7 +120,7 @@ class AuthenticationWebView extends React.PureComponent {
}}
/>
{ loading ? <ActivityIndicator size='large' style={styles.loading} /> : null }
</React.Fragment>
</>
);
}
}

View File

@ -85,7 +85,7 @@ export default class DirectoryOptions extends PureComponent {
});
const { globalUsers, toggleWorkspace, isFederationEnabled } = this.props;
return (
<React.Fragment>
<>
<TouchableWithoutFeedback onPress={this.close}>
<Animated.View style={[styles.backdrop, { opacity: backdropOpacity }]} />
</TouchableWithoutFeedback>
@ -103,7 +103,7 @@ export default class DirectoryOptions extends PureComponent {
{this.renderItem('users')}
{isFederationEnabled
? (
<React.Fragment>
<>
<View style={styles.dropdownSeparator} />
<View style={[styles.dropdownItemContainer, styles.globalUsersContainer]}>
<View style={styles.globalUsersTextContainer}>
@ -112,11 +112,11 @@ export default class DirectoryOptions extends PureComponent {
</View>
<Switch value={globalUsers} onValueChange={toggleWorkspace} trackColor={SWITCH_TRACK_COLOR} />
</View>
</React.Fragment>
</>
)
: null}
</Animated.View>
</React.Fragment>
</>
);
}
}

View File

@ -142,7 +142,7 @@ class DirectoryView extends React.Component {
renderHeader = () => {
const { type } = this.state;
return (
<React.Fragment>
<>
<SearchBox
onChangeText={this.onSearchChangeText}
onSubmitEditing={this.search}
@ -155,7 +155,7 @@ class DirectoryView extends React.Component {
<CustomIcon name='arrow-down' size={20} style={styles.toggleDropdownArrow} />
</View>
</Touch>
</React.Fragment>
</>
);
}

View File

@ -253,23 +253,23 @@ class RoomInfoView extends React.Component {
renderChannel = () => {
const { room } = this.state;
return (
<React.Fragment>
<>
{this.renderItem('description', room)}
{this.renderItem('topic', room)}
{this.renderItem('announcement', room)}
{room.broadcast ? this.renderBroadcast() : null}
</React.Fragment>
</>
);
}
renderDirect = () => {
const { roomUser } = this.state;
return (
<React.Fragment>
<>
{this.renderRoles()}
{this.renderTimezone()}
{this.renderCustomFields(roomUser._id)}
</React.Fragment>
</>
);
}

View File

@ -669,13 +669,13 @@ class RoomView extends React.Component {
if (showUnreadSeparator || dateSeparator) {
return (
<React.Fragment>
<>
{message}
<Separator
ts={dateSeparator}
unread={showUnreadSeparator}
/>
</React.Fragment>
</>
);
}

View File

@ -8,11 +8,11 @@ import Sort from './Sort';
const ListHeader = React.memo(({
searchLength, sortBy, onChangeSearchText, toggleSort, goDirectory
}) => (
<React.Fragment>
<>
<SearchBar onChangeSearchText={onChangeSearchText} />
<Directory goDirectory={goDirectory} />
<Sort searchLength={searchLength} sortBy={sortBy} toggleSort={toggleSort} />
</React.Fragment>
</>
));
ListHeader.propTypes = {

View File

@ -112,7 +112,7 @@ class Sort extends PureComponent {
} = this.props;
return (
<React.Fragment>
<>
<TouchableWithoutFeedback key='sort-backdrop' onPress={this.close}>
<Animated.View style={[styles.backdrop, { opacity: backdropOpacity }]} />
</TouchableWithoutFeedback>
@ -167,7 +167,7 @@ class Sort extends PureComponent {
</View>
</Touch>
</Animated.View>
</React.Fragment>
</>
);
}
}

View File

@ -312,7 +312,7 @@ class ShareListView extends React.Component {
const { server } = this.props;
const currentServer = servers.find(serverFiltered => serverFiltered.id === server);
return currentServer ? (
<React.Fragment>
<>
{this.renderSectionHeader('Select_Server')}
<View style={styles.bordered}>
<ServerItem
@ -321,7 +321,7 @@ class ShareListView extends React.Component {
item={currentServer}
/>
</View>
</React.Fragment>
</>
) : null;
}
@ -334,17 +334,17 @@ class ShareListView extends React.Component {
renderHeader = () => {
const { searching } = this.state;
return (
<React.Fragment>
<>
{ !searching
? (
<React.Fragment>
<>
{this.renderSelectServer()}
{this.renderSectionHeader('Chats')}
</React.Fragment>
</>
)
: null
}
</React.Fragment>
</>
);
}
@ -391,9 +391,9 @@ class ShareListView extends React.Component {
<View style={styles.container}>
{ !searching
? (
<React.Fragment>
<>
{this.renderSelectServer()}
</React.Fragment>
</>
)
: null
}

View File

@ -184,7 +184,7 @@ class Sidebar extends Component {
const { isAdmin } = this.state;
const { activeItemKey } = this.props;
return (
<React.Fragment>
<>
<SidebarItem
text={I18n.t('Chats')}
left={<CustomIcon name='message' size={20} color={COLOR_TEXT} />}
@ -222,7 +222,7 @@ class Sidebar extends Component {
onPress={this.logout}
testID='sidebar-logout'
/>
</React.Fragment>
</>
);
}