From a77a144f6faf0dc05208389428df61fd1d7bee98 Mon Sep 17 00:00:00 2001 From: Chandler Copeland Date: Sat, 21 Mar 2026 12:27:09 -0600 Subject: [PATCH] =?UTF-8?q?fix(09-01):=20fix=20hydration=20mismatch=20in?= =?UTF-8?q?=20TextFillForm=20=E2=80=94=20use=20useEffect=20for=20initialDa?= =?UTF-8?q?ta=20seed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../documents/[docId]/_components/TextFillForm.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/TextFillForm.tsx b/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/TextFillForm.tsx index 9e1a197..c72bebe 100644 --- a/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/TextFillForm.tsx +++ b/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/TextFillForm.tsx @@ -1,5 +1,5 @@ 'use client'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; interface TextRow { label: string; value: string; } @@ -17,7 +17,14 @@ function buildInitialRows(initialData?: Record): TextRow[] { } export function TextFillForm({ onChange, initialData }: TextFillFormProps) { - const [rows, setRows] = useState(() => buildInitialRows(initialData)); + const [rows, setRows] = useState([{ label: '', value: '' }]); + + useEffect(() => { + if (initialData && Object.keys(initialData).length > 0) { + setRows(buildInitialRows(initialData)); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); function updateRow(index: number, field: 'label' | 'value', val: string) { const next = rows.map((r, i) => i === index ? { ...r, [field]: val } : r);