Browse Source

Merge pull request #509 from gre/perf-pillsdayscount

save about 10ms at each re-render of Account Page
master
Meriadec Pillet 7 years ago
committed by GitHub
parent
commit
e454c983b7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 30
      src/components/PillsDaysCount.js

30
src/components/PillsDaysCount.js

@ -1,6 +1,6 @@
// @flow
import React from 'react'
import React, { PureComponent } from 'react'
import { translate } from 'react-i18next'
import type { T } from 'types/common'
@ -9,7 +9,7 @@ import Pills from 'components/base/Pills'
type Props = {
selectedTime: string,
onChange: Function,
onChange: ({ key: string, value: *, label: string }) => void,
t: T,
}
@ -19,18 +19,20 @@ const itemsTimes = [
{ key: 'year', value: 365 },
]
function PillsDaysCount(props: Props) {
const { selectedTime, onChange, t } = props
return (
<Pills
items={itemsTimes.map(item => ({
...item,
label: t(`time:${item.key}`),
}))}
activeKey={selectedTime}
onChange={onChange}
/>
)
class PillsDaysCount extends PureComponent<Props> {
render() {
const { selectedTime, onChange, t } = this.props
return (
<Pills
items={itemsTimes.map(item => ({
...item,
label: t(`time:${item.key}`),
}))}
activeKey={selectedTime}
onChange={onChange}
/>
)
}
}
export default translate()(PillsDaysCount)

Loading…
Cancel
Save