[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 <SendButton onPress={submit} />;
} }
return ( return (
<React.Fragment> <>
<AudioButton onPress={recordAudioMessage} /> <AudioButton onPress={recordAudioMessage} />
<FileButton onPress={showFileActions} /> <FileButton onPress={showFileActions} />
</React.Fragment> </>
); );
}); });

View File

@ -168,7 +168,7 @@ export default class Audio extends React.Component {
} }
return ( return (
<React.Fragment> <>
<View style={styles.audioContainer}> <View style={styles.audioContainer}>
<Video <Video
ref={this.setRef} ref={this.setRef}
@ -196,7 +196,7 @@ export default class Audio extends React.Component {
<Text style={styles.duration}>{this.duration}</Text> <Text style={styles.duration}>{this.duration}</Text>
</View> </View>
<Markdown msg={description} baseUrl={baseUrl} username={user.username} getCustomEmoji={getCustomEmoji} useMarkdown={useMarkdown} /> <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} style={styles.button}
hitSlop={BUTTON_HIT_SLOP} hitSlop={BUTTON_HIT_SLOP}
> >
<React.Fragment> <>
<CustomIcon name='back' size={20} style={styles.buttonIcon} /> <CustomIcon name='back' size={20} style={styles.buttonIcon} />
<Text style={styles.buttonText}>{I18n.t('Reply')}</Text> <Text style={styles.buttonText}>{I18n.t('Reply')}</Text>
</React.Fragment> </>
</Touchable> </Touchable>
</View> </View>
); );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -200,13 +200,13 @@ class NotificationBadge extends React.Component {
hitSlop={BUTTON_HIT_SLOP} hitSlop={BUTTON_HIT_SLOP}
background={Touchable.SelectableBackgroundBorderless()} background={Touchable.SelectableBackgroundBorderless()}
> >
<React.Fragment> <>
<Avatar text={name} size={AVATAR_SIZE} type={type} baseUrl={baseUrl} style={styles.avatar} userId={userId} token={token} /> <Avatar text={name} size={AVATAR_SIZE} type={type} baseUrl={baseUrl} style={styles.avatar} userId={userId} token={token} />
<View> <View>
<Text style={styles.roomName}>{name}</Text> <Text style={styles.roomName}>{name}</Text>
<Text style={[styles.message, { maxWidth: maxWidthMessage }]} numberOfLines={1}>{message}</Text> <Text style={[styles.message, { maxWidth: maxWidthMessage }]} numberOfLines={1}>{message}</Text>
</View> </View>
</React.Fragment> </>
</Touchable> </Touchable>
<TouchableOpacity onPress={this.hide}> <TouchableOpacity onPress={this.hide}>
<CustomIcon name='circle-cross' style={styles.close} size={20} /> <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}> <RectButton style={styles.actionButton} onPress={onToggleReadPress}>
<React.Fragment> <>
<CustomIcon size={20} name={isRead ? 'flag' : 'check'} color='white' /> <CustomIcon size={20} name={isRead ? 'flag' : 'check'} color='white' />
<Text style={styles.actionText}>{I18n.t(isRead ? 'Unread' : 'Read')}</Text> <Text style={styles.actionText}>{I18n.t(isRead ? 'Unread' : 'Read')}</Text>
</React.Fragment> </>
</RectButton> </RectButton>
</Animated.View> </Animated.View>
</Animated.View> </Animated.View>
@ -87,10 +87,10 @@ export const RightActions = React.memo(({
]} ]}
> >
<RectButton style={[styles.actionButton, { backgroundColor: '#ffbb00' }]} onPress={toggleFav}> <RectButton style={[styles.actionButton, { backgroundColor: '#ffbb00' }]} onPress={toggleFav}>
<React.Fragment> <>
<CustomIcon size={20} name={favorite ? 'Star-filled' : 'star'} color='white' /> <CustomIcon size={20} name={favorite ? 'Star-filled' : 'star'} color='white' />
<Text style={styles.actionText}>{I18n.t(favorite ? 'Unfavorite' : 'Favorite')}</Text> <Text style={styles.actionText}>{I18n.t(favorite ? 'Unfavorite' : 'Favorite')}</Text>
</React.Fragment> </>
</RectButton> </RectButton>
</Animated.View> </Animated.View>
<Animated.View <Animated.View
@ -103,10 +103,10 @@ export const RightActions = React.memo(({
]} ]}
> >
<RectButton style={[styles.actionButton, { backgroundColor: '#54585e' }]} onPress={onHidePress}> <RectButton style={[styles.actionButton, { backgroundColor: '#54585e' }]} onPress={onHidePress}>
<React.Fragment> <>
<CustomIcon size={20} name='eye-off' color='white' /> <CustomIcon size={20} name='eye-off' color='white' />
<Text style={styles.actionText}>{I18n.t('Hide')}</Text> <Text style={styles.actionText}>{I18n.t('Hide')}</Text>
</React.Fragment> </>
</RectButton> </RectButton>
</Animated.View> </Animated.View>
</View> </View>

View File

@ -12,8 +12,8 @@ const styles = StyleSheet.create({
}); });
export default React.memo(() => ( export default React.memo(() => (
<React.Fragment> <>
<StatusBar /> <StatusBar />
{isAndroid ? <Image source={{ uri: 'launch_screen' }} style={styles.image} /> : null} {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 { loading } = this.state;
const uri = navigation.getParam('url'); const uri = navigation.getParam('url');
return ( return (
<React.Fragment> <>
<StatusBar /> <StatusBar />
<WebView <WebView
useWebKit useWebKit
@ -120,7 +120,7 @@ class AuthenticationWebView extends React.PureComponent {
}} }}
/> />
{ loading ? <ActivityIndicator size='large' style={styles.loading} /> : null } { 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; const { globalUsers, toggleWorkspace, isFederationEnabled } = this.props;
return ( return (
<React.Fragment> <>
<TouchableWithoutFeedback onPress={this.close}> <TouchableWithoutFeedback onPress={this.close}>
<Animated.View style={[styles.backdrop, { opacity: backdropOpacity }]} /> <Animated.View style={[styles.backdrop, { opacity: backdropOpacity }]} />
</TouchableWithoutFeedback> </TouchableWithoutFeedback>
@ -103,7 +103,7 @@ export default class DirectoryOptions extends PureComponent {
{this.renderItem('users')} {this.renderItem('users')}
{isFederationEnabled {isFederationEnabled
? ( ? (
<React.Fragment> <>
<View style={styles.dropdownSeparator} /> <View style={styles.dropdownSeparator} />
<View style={[styles.dropdownItemContainer, styles.globalUsersContainer]}> <View style={[styles.dropdownItemContainer, styles.globalUsersContainer]}>
<View style={styles.globalUsersTextContainer}> <View style={styles.globalUsersTextContainer}>
@ -112,11 +112,11 @@ export default class DirectoryOptions extends PureComponent {
</View> </View>
<Switch value={globalUsers} onValueChange={toggleWorkspace} trackColor={SWITCH_TRACK_COLOR} /> <Switch value={globalUsers} onValueChange={toggleWorkspace} trackColor={SWITCH_TRACK_COLOR} />
</View> </View>
</React.Fragment> </>
) )
: null} : null}
</Animated.View> </Animated.View>
</React.Fragment> </>
); );
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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