fix(shell): initialize activeTabRef with activeTab and move useEffect
Reorder code to follow React hooks rules - initialize ref with value instead of null, then update via useEffect. 💘 Generated with Crush Assisted-by: MiniMax-M2.7 via Crush <crush@charm.land>
This commit is contained in:
@@ -204,11 +204,8 @@ export default function Shell({ api }) {
|
|||||||
const tabsRef = useRef({})
|
const tabsRef = useRef({})
|
||||||
const nextIdRef = useRef(1)
|
const nextIdRef = useRef(1)
|
||||||
const settingsRef = useRef({ fontSize: 12, fontFamily: "'JetBrains Mono', 'Fira Code', monospace", theme: 'default' })
|
const settingsRef = useRef({ fontSize: 12, fontFamily: "'JetBrains Mono', 'Fira Code', monospace", theme: 'default' })
|
||||||
const activeTabRef = useRef(null)
|
|
||||||
const pendingCommandsRef = useRef({})
|
const pendingCommandsRef = useRef({})
|
||||||
|
|
||||||
useEffect(() => { activeTabRef.current = activeTab }, [activeTab])
|
|
||||||
|
|
||||||
const savedTabs = (() => {
|
const savedTabs = (() => {
|
||||||
try {
|
try {
|
||||||
const raw = localStorage.getItem(TABS_STORAGE_KEY)
|
const raw = localStorage.getItem(TABS_STORAGE_KEY)
|
||||||
@@ -231,6 +228,8 @@ export default function Shell({ api }) {
|
|||||||
}
|
}
|
||||||
return 1
|
return 1
|
||||||
})
|
})
|
||||||
|
const activeTabRef = useRef(activeTab)
|
||||||
|
useEffect(() => { activeTabRef.current = activeTab }, [activeTab])
|
||||||
const [sshConnections, setSshConnections] = useState([])
|
const [sshConnections, setSshConnections] = useState([])
|
||||||
const [systemTerminals, setSystemTerminals] = useState([])
|
const [systemTerminals, setSystemTerminals] = useState([])
|
||||||
const [showMenu, setShowMenu] = useState(false)
|
const [showMenu, setShowMenu] = useState(false)
|
||||||
|
|||||||
Reference in New Issue
Block a user