MCPcopy
hub / github.com/primer/react / getServerHandoff

Function getServerHandoff

packages/react/src/ThemeProvider.tsx:43–51  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

41
42// inspired from __NEXT_DATA__, we use application/json to avoid CSRF policy with inline scripts
43const getServerHandoff = (id: string) => {
44 try {
45 const serverData = document.getElementById(`__PRIMER_DATA_${id}__`)?.textContent
46 if (serverData) return JSON.parse(serverData)
47 } catch (error) {
48 // if document/element does not exist or JSON is invalid, supress error
49 }
50 return {}
51}
52
53export const ThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderProps>> = ({children, ...props}) => {
54 // Get fallback values from parent ThemeProvider (if exists)

Callers 1

ThemeProviderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected