mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-08-08 16:07:44 +00:00
refactor: inline function
This commit is contained in:
parent
52aa5ee131
commit
a1b94a68ff
1 changed files with 6 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2017-2024 Smart code 203358507
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import Button from 'stremio/common/Button';
|
||||
import styles from './Option.less';
|
||||
|
|
@ -16,11 +16,15 @@ const Option = ({ option, selectedOption, onSelect }: Props) => {
|
|||
// consider using option.id === selectedOption?.id instead
|
||||
const selected = useMemo(() => option?.value === selectedOption?.value, [option, selectedOption]);
|
||||
|
||||
const handleClick = useCallback(() => {
|
||||
onSelect(option.value);
|
||||
}, [onSelect, option.value]);
|
||||
|
||||
return (
|
||||
<Button
|
||||
className={classNames(styles['option'], { [styles['selected']]: selected })}
|
||||
key={option.id}
|
||||
onClick={() => onSelect(option.value)}
|
||||
onClick={handleClick}
|
||||
aria-selected={selected}
|
||||
>
|
||||
<div className={styles['label']}>{ option.label }</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue