File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
packages/compass-components/src/hooks Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -2,15 +2,20 @@ import { formatDate } from '../utils/format-date';
22
33import { useState , useEffect } from 'react' ;
44
5- export function useFormattedDate ( timestamp ?: number ) {
6- const [ formattedDate , setFormattedDate ] = useState (
7- ( ) => timestamp && formatDate ( timestamp )
5+ export function useFormattedDate ( timestamp : number ) : string ;
6+ export function useFormattedDate ( timestamp ?: number ) : string | undefined {
7+ const [ formattedDate , setFormattedDate ] = useState ( ( ) =>
8+ typeof timestamp === 'number' ? formatDate ( timestamp ) : undefined
89 ) ;
910
1011 useEffect ( ( ) => {
11- setFormattedDate ( timestamp && formatDate ( timestamp ) ) ;
12+ setFormattedDate (
13+ typeof timestamp === 'number' ? formatDate ( timestamp ) : undefined
14+ ) ;
1215 const interval = setInterval ( ( ) => {
13- setFormattedDate ( timestamp && formatDate ( timestamp ) ) ;
16+ setFormattedDate (
17+ typeof timestamp === 'number' ? formatDate ( timestamp ) : undefined
18+ ) ;
1419 } , 1000 * 60 ) ;
1520 return ( ) => {
1621 clearInterval ( interval ) ;
You can’t perform that action at this time.
0 commit comments