import {createContext, useContext, useState} from 'react'; import Alert from 'sentry/components/alert'; const pageErrorContext = createContext<{ setPageError: (error: string | undefined) => void; pageError?: string; }>({ pageError: undefined, setPageError: (_: string | undefined) => {}, }); export const PageErrorProvider = ({children}: {children: React.ReactNode}) => { const [pageError, setPageError] = useState(); return ( {children} ); }; export const PageErrorAlert = () => { const {pageError} = useContext(pageErrorContext); if (!pageError) { return null; } return ( {pageError} ); }; export const usePageError = () => useContext(pageErrorContext);