Merge branch 'main' into franknoirot/4088/create-file-url

This commit is contained in:
Frank Noirot
2025-01-08 12:00:19 -05:00
parent c29be6e341
commit 28eb99f655
1198 changed files with 422117 additions and 69676 deletions

View File

@ -0,0 +1,33 @@
import { useEffect, useState, createContext, ReactNode } from 'react'
import { useNavigation, useLocation } from 'react-router-dom'
import { PATHS } from 'lib/paths'
import { markOnce } from 'lib/performance'
export const RouteProviderContext = createContext({})
export function RouteProvider({ children }: { children: ReactNode }) {
const [first, setFirstState] = useState(true)
const navigation = useNavigation()
const location = useLocation()
useEffect(() => {
// On initialization, the react-router-dom does not send a 'loading' state event.
// it sends an idle event first.
const pathname = first ? location.pathname : navigation.location?.pathname
const isHome = pathname === PATHS.HOME
const isFile =
pathname?.includes(PATHS.FILE) &&
pathname?.substring(pathname?.length - 4) === '.kcl'
if (isHome) {
markOnce('code/willLoadHome')
} else if (isFile) {
markOnce('code/willLoadFile')
}
setFirstState(false)
}, [navigation])
return (
<RouteProviderContext.Provider value={{}}>
{children}
</RouteProviderContext.Provider>
)
}