feat: implement Year Review feature with session management, item categorization, and real-time collaboration
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 6m7s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 6m7s
This commit is contained in:
@@ -18,6 +18,7 @@ export function EditableMotivatorTitle({
|
||||
const [title, setTitle] = useState(initialTitle);
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const prevInitialTitleRef = useRef(initialTitle);
|
||||
|
||||
useEffect(() => {
|
||||
if (isEditing && inputRef.current) {
|
||||
@@ -26,9 +27,14 @@ export function EditableMotivatorTitle({
|
||||
}
|
||||
}, [isEditing]);
|
||||
|
||||
// Update local state when prop changes (e.g., from SSE)
|
||||
// Update local state when prop changes (e.g., from SSE) - only when not editing
|
||||
// This is a valid pattern for syncing external state (SSE updates) with local state
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
useEffect(() => {
|
||||
if (!isEditing) {
|
||||
if (!isEditing && prevInitialTitleRef.current !== initialTitle) {
|
||||
prevInitialTitleRef.current = initialTitle;
|
||||
// Synchronizing with external prop updates (e.g., from SSE)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
setTitle(initialTitle);
|
||||
}
|
||||
}, [initialTitle, isEditing]);
|
||||
|
||||
Reference in New Issue
Block a user