mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-19 06:30:10 +08:00
fix(HeaderNavbar): use startTransition for title update in useEffect to avoid synchronously setState
fix: Error: Calling setState synchronously within an effect can trigger cascading renders
This commit is contained in:
parent
a5865cfd01
commit
84f590ec7b
@ -9,7 +9,7 @@ import { findNode } from '@renderer/services/NotesTreeService'
|
||||
import { Dropdown, Input, Tooltip } from 'antd'
|
||||
import { t } from 'i18next'
|
||||
import { MoreHorizontal, PanelLeftClose, PanelRightClose, Star } from 'lucide-react'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { startTransition, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import { menuItems } from './MenuConfig'
|
||||
@ -138,7 +138,7 @@ const HeaderNavbar = ({ notesTree, getCurrentNoteContent, onToggleStar, onExpand
|
||||
// 同步标题值
|
||||
useEffect(() => {
|
||||
if (activeNode?.type === 'file') {
|
||||
setTitleValue(activeNode.name.replace('.md', ''))
|
||||
startTransition(() => setTitleValue(activeNode.name.replace('.md', '')))
|
||||
}
|
||||
}, [activeNode])
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user