mirror of
https://github.com/zvx-echo6/navi.git
synced 2026-05-20 22:54:42 +02:00
fix: usePanelState returns string, preview decoupled from route
Fixes React error #185 (infinite re-render loop) caused by returning object from Zustand selector without shallow comparison. Changed usePanelState to return string states that encode both preview and route status: - PREVIEW_CALCULATED: preview + calculated route - PREVIEW_ROUTING: preview + stops (no route yet) - PREVIEW: preview only - ROUTE_CALCULATED: calculated route only - ROUTING: stops only - IDLE: nothing Panel.jsx updated to derive show flags from string states using startsWith and includes checks.
This commit is contained in:
parent
f5e0b9606e
commit
721bc2c9f5
2 changed files with 20 additions and 14 deletions
|
|
@ -32,7 +32,7 @@ export default function Panel({ onManeuverClick }) {
|
|||
const activeTab = useStore((s) => s.activeTab)
|
||||
const setActiveTab = useStore((s) => s.setActiveTab)
|
||||
|
||||
const { hasPreview, routeState } = usePanelState()
|
||||
const panelState = usePanelState()
|
||||
|
||||
const [isMobile, setIsMobile] = useState(false)
|
||||
const [optimizing, setOptimizing] = useState(false)
|
||||
|
|
@ -126,11 +126,11 @@ export default function Panel({ onManeuverClick }) {
|
|||
|
||||
const showOptimize = effectiveCount >= 3
|
||||
|
||||
// Determine what to show based on panel state (preview and route are now orthogonal)
|
||||
const showPreviewCard = hasPreview
|
||||
const showRouteSection = routeState === 'ROUTING' || routeState === 'CALCULATED'
|
||||
const showManeuvers = routeState === 'CALCULATED'
|
||||
const showEmptyState = !hasPreview && routeState === 'NONE'
|
||||
// Determine what to show based on panel state
|
||||
const showPreviewCard = panelState.startsWith('PREVIEW')
|
||||
const showRouteSection = ['ROUTING', 'ROUTE_CALCULATED', 'PREVIEW_ROUTING', 'PREVIEW_CALCULATED'].includes(panelState)
|
||||
const showManeuvers = panelState === 'ROUTE_CALCULATED' || panelState === 'PREVIEW_CALCULATED'
|
||||
const showEmptyState = panelState === 'IDLE'
|
||||
|
||||
// Routes tab content - now state-driven
|
||||
const routesContent = (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue