Skip to content

Commit

Permalink
Memoize nav switcher and lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstotsky committed Jun 18, 2024
1 parent ce4363f commit 5360003
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/ui/NavSwitcher/NavSwitcher.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from 'react'
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import _map from 'lodash/map'
import { isEqual } from '@bitfinex/lib-js-util-base'

import { tracker } from 'utils/trackers'

const NavSwitcher = (props) => {
const { items, onChange, value: activeItem } = props
const NavSwitcher = ({
items,
onChange,
value: activeItem,
}) => {
const handleClick = (itemValue) => {
tracker.trackEvent(itemValue, 'Tab')
onChange(itemValue)
Expand All @@ -22,7 +25,11 @@ const NavSwitcher = (props) => {
})

return (
<span className={itemClasses} onClick={() => handleClick(itemValue)} key={itemValue}>
<span
key={itemValue}
className={itemClasses}
onClick={() => handleClick(itemValue)}
>
{label}
</span>
)
Expand All @@ -40,4 +47,4 @@ NavSwitcher.propTypes = {
value: PropTypes.string.isRequired,
}

export default NavSwitcher
export default memo(NavSwitcher)

0 comments on commit 5360003

Please sign in to comment.