perf(supplies): optimize React components with memo and callbacks
ФАЗА 2: Оптимизация производительности завершена: - Обернуты все блок-компоненты в React.memo для предотвращения лишних ререндеров - Добавлены useCallback для всех обработчиков событий в главном компоненте - Оптимизированы зависимости для минимизации пересоздания функций - Страница остается полностью функциональной Компоненты с memo: SuppliersBlock, ProductCardsBlock, DetailedCatalogBlock, CartBlock Callbacks: handleSupplierSelect, handleProductAdd, handleQuantityChange, handleRecipeChange 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -9,12 +9,17 @@
|
||||
|
||||
import { Package, Plus } from 'lucide-react'
|
||||
import Image from 'next/image'
|
||||
import React from 'react'
|
||||
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
|
||||
import type { ProductCardsBlockProps } from '../types/supply-creation.types'
|
||||
|
||||
export function ProductCardsBlock({ products, selectedSupplier, onProductAdd }: ProductCardsBlockProps) {
|
||||
export const ProductCardsBlock = React.memo(function ProductCardsBlock({
|
||||
products,
|
||||
selectedSupplier,
|
||||
onProductAdd,
|
||||
}: ProductCardsBlockProps) {
|
||||
if (!selectedSupplier) {
|
||||
return (
|
||||
<div className="bg-white/10 backdrop-blur-xl border border-white/20 rounded-2xl p-6">
|
||||
@ -141,4 +146,4 @@ export function ProductCardsBlock({ products, selectedSupplier, onProductAdd }:
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user