Skip to content

Commit

Permalink
refactor: rm unnecessary memo
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Dec 19, 2023
1 parent 72af1a7 commit 4c4b25f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/features/cpu/RegisterTableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memo } from 'react'
import { type FC, memo } from 'react'

import { NO_BREAK_SPACE } from '@/common/constants'
import { decToBin, decToHex, sign8 } from '@/common/utils'
Expand Down Expand Up @@ -37,14 +37,14 @@ if (import.meta.env.DEV) {
RegisterTableRow.displayName = 'RegisterTableRow'
}

const FlagIndicator = memo(() => (
const FlagIndicator: FC = () => (
<tr>
<td>{NO_BREAK_SPACE}</td>
<td />
<RegisterValueTableCell.FlagIndicator />
<td />
</tr>
))
)

if (import.meta.env.DEV) {
FlagIndicator.displayName = 'RegisterTableRow.FlagIndicator'
Expand Down
14 changes: 5 additions & 9 deletions src/features/io/SevenSegmentDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createNextState } from '@reduxjs/toolkit'
import { type FC, memo, useEffect, useState } from 'react'
import { type FC, useEffect, useState } from 'react'
import { map } from 'rxjs'

import { store } from '@/app/store'
Expand All @@ -10,7 +10,7 @@ import DeviceCard from './DeviceCard'
import { useIoDevice } from './hooks'
import { type IoDeviceData, IoDeviceName, resetIoState } from './ioSlice'

const StaticParts = memo(() => (
const staticParts = (
<>
<rect fill="#a1a1aa" height="300" width="320">
<title>Background</title>
Expand Down Expand Up @@ -105,13 +105,9 @@ const StaticParts = memo(() => (
</text>
</g>
</>
))
)

if (import.meta.env.DEV) {
StaticParts.displayName = 'StaticParts'
}

const segments: readonly JSX.Element[] = [
const segments = [
// 0
<polygon key={0} points="56,64 104,64 96,72 64,72" />,
<polygon key={1} points="208,64 256,64 248,72 216,72" />,
Expand Down Expand Up @@ -180,7 +176,7 @@ const SevenSegmentDisplay: FC = () => {
<svg viewBox="0 0 320 300" width="320" xmlns="http://www.w3.org/2000/svg">
<g>
<title>Static Layer</title>
<StaticParts />
{staticParts}
</g>
<g fill="lime" stroke="lime" strokeWidth="2">
<title>Segments Layer</title>
Expand Down
12 changes: 4 additions & 8 deletions src/features/io/TrafficLights.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { type FC, memo } from 'react'
import type { FC } from 'react'

import { range } from '@/common/utils'

import DeviceCard from './DeviceCard'
import { useIoDevice } from './hooks'
import { IoDeviceName } from './ioSlice'

const StaticParts = memo(() => (
const staticParts = (
<>
<rect fill="#a1a1aa" height="120" width="320" x="0" y="120">
<title>Background</title>
Expand Down Expand Up @@ -52,11 +52,7 @@ const StaticParts = memo(() => (
</text>
</g>
</>
))

if (import.meta.env.DEV) {
StaticParts.displayName = 'StaticParts'
}
)

const lightColors = ['red', 'yellow', 'lime'] as const

Expand All @@ -72,7 +68,7 @@ const TrafficLights: FC = () => {
<svg viewBox="0 0 312 240" width="312" xmlns="http://www.w3.org/2000/svg">
<g>
<title>Static Layer</title>
<StaticParts />
{staticParts}
</g>
<g>
<title>Lights Layer</title>
Expand Down

0 comments on commit 4c4b25f

Please sign in to comment.