-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client: fix and improve memoization of "ProgressBar"
- Loading branch information
Showing
8 changed files
with
77 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
import {FC, memo, ReactNode} from 'react'; | ||
import {FC} from 'react'; | ||
import {observer} from 'mobx-react'; | ||
|
||
import type {TorrentStatus} from '@shared/constants/torrentStatusMap'; | ||
|
||
import TorrentStatusIcon from './TorrentStatusIcon'; | ||
|
||
interface ProgressBarProps { | ||
percent: number; | ||
icon?: ReactNode; | ||
status?: TorrentStatus; | ||
} | ||
|
||
const ProgressBar: FC<ProgressBarProps> = memo(({percent, icon}: ProgressBarProps) => ( | ||
const ProgressBar: FC<ProgressBarProps> = observer(({percent, status}: ProgressBarProps) => ( | ||
<div className="progress-bar"> | ||
<div className="progress-bar__icon">{icon}</div> | ||
<div className="progress-bar__icon">{status && <TorrentStatusIcon status={status} />}</div> | ||
<div className="progress-bar__fill__wrapper"> | ||
<div className="progress-bar__fill" style={{width: `${percent}%`}} /> | ||
</div> | ||
</div> | ||
)); | ||
|
||
ProgressBar.defaultProps = { | ||
icon: undefined, | ||
status: undefined, | ||
}; | ||
|
||
export default ProgressBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters