8a93321fb1
* Consider observer(...) as components * Add display names to MobX observers * Temporarily suppress nested components * Suppress new false positives for react/prop-types
25 lines
663 B
TypeScript
25 lines
663 B
TypeScript
import React from 'react'
|
|
import {observer} from 'mobx-react-lite'
|
|
import {ago} from 'lib/strings/time'
|
|
import {useStores} from 'state/index'
|
|
|
|
// FIXME(dan): Figure out why the false positives
|
|
/* eslint-disable react/prop-types */
|
|
|
|
export const TimeElapsed = observer(function TimeElapsed({
|
|
timestamp,
|
|
children,
|
|
}: {
|
|
timestamp: string
|
|
children: ({timeElapsed}: {timeElapsed: string}) => JSX.Element
|
|
}) {
|
|
const stores = useStores()
|
|
const [timeElapsed, setTimeAgo] = React.useState(ago(timestamp))
|
|
|
|
React.useEffect(() => {
|
|
setTimeAgo(ago(timestamp))
|
|
}, [timestamp, setTimeAgo, stores.shell.tickEveryMinute])
|
|
|
|
return children({timeElapsed})
|
|
})
|