mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-21 03:36:35 +00:00
fix: remove manual useMemo
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useMemo, useState } from "react"
|
||||
import { useState } from "react"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Field, FieldError, FieldTitle } from "@/components/ui/field"
|
||||
@@ -99,10 +99,7 @@ export function AttributesEditor({
|
||||
error,
|
||||
isSuccess,
|
||||
}: AttributesEditorProps) {
|
||||
const initial = useMemo(
|
||||
() => buildInitial(specs, attributes),
|
||||
[specs, attributes],
|
||||
)
|
||||
const initial = buildInitial(specs, attributes)
|
||||
const [values, setValues] = useState(initial)
|
||||
|
||||
const setValue = (key: string, value: string) => {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import type { SecurityGroup } from "@aws-sdk/client-ec2"
|
||||
import { useMemo, useState } from "react"
|
||||
import { useState } from "react"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
|
||||
@@ -30,7 +30,7 @@ export function SecurityGroupsEditor({
|
||||
error,
|
||||
isSuccess,
|
||||
}: SecurityGroupsEditorProps) {
|
||||
const initial = useMemo(() => [...current], [current])
|
||||
const initial = [...current]
|
||||
const [selected, setSelected] = useState<string[]>(initial)
|
||||
|
||||
const toggle = (id: string) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Subnet } from "@aws-sdk/client-ec2"
|
||||
import { useMemo, useState } from "react"
|
||||
import { useState } from "react"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { getNameTag } from "@/lib/utils"
|
||||
@@ -38,7 +38,7 @@ export function SubnetsEditor({
|
||||
error,
|
||||
isSuccess,
|
||||
}: SubnetsEditorProps) {
|
||||
const initial = useMemo(() => [...current], [current])
|
||||
const initial = [...current]
|
||||
const [selected, setSelected] = useState<string[]>(initial)
|
||||
|
||||
const toggle = (id: string) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Plus, Trash2 } from "lucide-react"
|
||||
import { useMemo, useState } from "react"
|
||||
import { useState } from "react"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
@@ -43,7 +43,7 @@ export function TagsEditor({
|
||||
error,
|
||||
isSuccess,
|
||||
}: TagsEditorProps) {
|
||||
const initialRows = useMemo(() => buildInitialRows(tags), [tags])
|
||||
const initialRows = buildInitialRows(tags)
|
||||
|
||||
const [rows, setRows] = useState<TagRow[]>(initialRows)
|
||||
const [nextId, setNextId] = useState(initialRows.length)
|
||||
|
||||
@@ -75,6 +75,8 @@ export function GpuInstanceTypeSelect({
|
||||
className,
|
||||
"aria-invalid": ariaInvalid,
|
||||
}: GpuInstanceTypeSelectProps) {
|
||||
// Pins the dedupe and sort to instanceTypes; without it the compiler widens
|
||||
// the scope to every prop and redoes the work on each selection change.
|
||||
const { standardEntries, gpuEntries } = useMemo(() => {
|
||||
const entries = dedupeInstanceTypes(instanceTypes)
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user