1
0
mirror of synced 2025-12-20 18:36:31 -05:00
Files
docs/components/context/DotComAuthenticatedContext.tsx
Peter Bengtsson 18504871b9 cache full rendering (#25424)
* cache full rendering

* still not working with gzip

* progress progress progress

* smaller

* hacky progress

* small fixes

* wip

* lock file

* wip

* wip

* package-lock updates

* wip

* search DOM in lowercase

* simplify

* with instrument

* improve test coverage

* mutateCheeriobodyByRequest

* fix

* remove renderContentCacheByContex

* disable render caching in sync-search

* diables things in github/github link checker

* gzip lru

* tidying up

* updated

* correct tests

* fix: move userLanguage to LanguagesContext

* Revert "fix: move userLanguage to LanguagesContext"

This reverts commit d7c05d958c71eaad496eb46764eb845d80b866ca.

* contexts ftw

* fixed rendering tests

* oops for got new file

* nits addressed

Co-authored-by: Mike Surowiec <mikesurowiec@users.noreply.github.com>
2022-05-23 12:12:09 +00:00

20 lines
504 B
TypeScript

import { createContext, useContext } from 'react'
export type DotComAuthenticatedContextT = {
isDotComAuthenticated: boolean
}
export const DotComAuthenticatedContext = createContext<DotComAuthenticatedContextT | null>(null)
export const useAuth = (): DotComAuthenticatedContextT => {
const context = useContext(DotComAuthenticatedContext)
if (!context) {
throw new Error(
'"useAuthContext" may only be used inside "DotComAuthenticatedContext.Provider"'
)
}
return context
}