-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(feedback): Create a store so we can track feedback integration lo…
…ading and re-render (#73056) This adds a context that we can use to store the loaded Feedback integration, and re-render children when that thing is loaded. It's got to be at the top of the react heirarchy like this because feedback is also loaded high in the tree and rendered everywhere. See getsentry/getsentry#14390 Related to getsentry/team-replay#438
- Loading branch information
Showing
3 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {createContext, useContext, useState} from 'react'; | ||
import type {addIntegration} from '@sentry/react'; | ||
|
||
type Integration = Parameters<typeof addIntegration>[0]; | ||
|
||
type State = Record<string, Integration | undefined>; | ||
|
||
const context = createContext<{ | ||
setState: React.Dispatch<React.SetStateAction<State>>; | ||
state: State; | ||
}>({ | ||
setState: () => {}, | ||
state: {}, | ||
}); | ||
|
||
export function AsyncSDKIntegrationContextProvider({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
const [state, setState] = useState<State>({}); | ||
|
||
return <context.Provider value={{setState, state}}>{children}</context.Provider>; | ||
} | ||
|
||
export default function useAsyncSDKIntegrationStore() { | ||
return useContext(context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters