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

Loading…
Cancel
Save