Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3347070
D9050.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
971 B
Referenced Files
None
Subscribers
None
D9050.diff
View Options
diff --git a/native/chat/timestamp.react.js b/native/chat/timestamp.react.js
--- a/native/chat/timestamp.react.js
+++ b/native/chat/timestamp.react.js
@@ -15,11 +15,25 @@
};
function Timestamp(props: Props): React.Node {
const styles = useStyles(unboundStyles);
- const style = [styles.timestamp];
- if (props.display === 'modal') {
- style.push(styles.modal);
- }
- return <SingleLine style={style}>{longAbsoluteDate(props.time)}</SingleLine>;
+ const style = React.useMemo(
+ () =>
+ props.display === 'modal'
+ ? [styles.timestamp, styles.modal]
+ : [styles.timestamp],
+ [props.display, styles.modal, styles.timestamp],
+ );
+
+ const absoluteDate = React.useMemo(
+ () => longAbsoluteDate(props.time),
+ [props.time],
+ );
+
+ const timestamp = React.useMemo(
+ () => <SingleLine style={style}>{absoluteDate}</SingleLine>,
+ [absoluteDate, style],
+ );
+
+ return timestamp;
}
const timestampHeight = 26;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 11:00 AM (18 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2570315
Default Alt Text
D9050.diff (971 B)
Attached To
Mode
D9050: [native] Add some memoization to `Timestamp` component
Attached
Detach File
Event Timeline
Log In to Comment