Improve perf of post rendering

zio/stable
Paul Frazee 2022-11-17 13:02:53 -06:00
parent 5d7f3e1863
commit 8b584c8c09
1 changed files with 3 additions and 7 deletions

View File

@ -1,5 +1,5 @@
import React, {useMemo} from 'react' import React, {useMemo} from 'react'
import {StyleSheet, useWindowDimensions, Text, View} from 'react-native' import {StyleSheet, Text, View} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {Link} from '../util/Link' import {Link} from '../util/Link'
import {PostDropdownBtn} from '../util/DropdownBtn' import {PostDropdownBtn} from '../util/DropdownBtn'
@ -18,15 +18,10 @@ interface PostMetaOpts {
} }
export function PostMeta(opts: PostMetaOpts) { export function PostMeta(opts: PostMetaOpts) {
const winDim = useWindowDimensions()
const maxWidth = useMemo(
() => ({maxWidth: ((winDim.width * 3) / 5) | 0}),
[winDim.width],
)
return ( return (
<View style={styles.meta}> <View style={styles.meta}>
<Link <Link
style={[styles.metaItem, maxWidth]} style={styles.metaItem}
href={opts.authorHref} href={opts.authorHref}
title={opts.authorHandle}> title={opts.authorHandle}>
<Text style={[s.f17, s.bold]} numberOfLines={1}> <Text style={[s.f17, s.bold]} numberOfLines={1}>
@ -61,5 +56,6 @@ const styles = StyleSheet.create({
}, },
metaItem: { metaItem: {
paddingRight: 5, paddingRight: 5,
maxWidth: '75%',
}, },
}) })