chore: add display name to context providers (#5974)
* chore: add display name to context providers * fix typo
This commit is contained in:
parent
5854ac3eed
commit
0ebe6292a3
@ -285,18 +285,21 @@ const deviceContextInitialValue = {
|
|||||||
canDeviceFitSidebar: false,
|
canDeviceFitSidebar: false,
|
||||||
};
|
};
|
||||||
const DeviceContext = React.createContext<Device>(deviceContextInitialValue);
|
const DeviceContext = React.createContext<Device>(deviceContextInitialValue);
|
||||||
|
DeviceContext.displayName = "DeviceContext";
|
||||||
export const useDevice = () => useContext<Device>(DeviceContext);
|
export const useDevice = () => useContext<Device>(DeviceContext);
|
||||||
|
|
||||||
const ExcalidrawContainerContext = React.createContext<{
|
const ExcalidrawContainerContext = React.createContext<{
|
||||||
container: HTMLDivElement | null;
|
container: HTMLDivElement | null;
|
||||||
id: string | null;
|
id: string | null;
|
||||||
}>({ container: null, id: null });
|
}>({ container: null, id: null });
|
||||||
|
ExcalidrawContainerContext.displayName = "ExcalidrawContainerContext";
|
||||||
export const useExcalidrawContainer = () =>
|
export const useExcalidrawContainer = () =>
|
||||||
useContext(ExcalidrawContainerContext);
|
useContext(ExcalidrawContainerContext);
|
||||||
|
|
||||||
const ExcalidrawElementsContext = React.createContext<
|
const ExcalidrawElementsContext = React.createContext<
|
||||||
readonly NonDeletedExcalidrawElement[]
|
readonly NonDeletedExcalidrawElement[]
|
||||||
>([]);
|
>([]);
|
||||||
|
ExcalidrawElementsContext.displayName = "ExcalidrawElementsContext";
|
||||||
|
|
||||||
const ExcalidrawAppStateContext = React.createContext<AppState>({
|
const ExcalidrawAppStateContext = React.createContext<AppState>({
|
||||||
...getDefaultAppState(),
|
...getDefaultAppState(),
|
||||||
@ -305,17 +308,19 @@ const ExcalidrawAppStateContext = React.createContext<AppState>({
|
|||||||
offsetLeft: 0,
|
offsetLeft: 0,
|
||||||
offsetTop: 0,
|
offsetTop: 0,
|
||||||
});
|
});
|
||||||
|
ExcalidrawAppStateContext.displayName = "ExcalidrawAppStateContext";
|
||||||
|
|
||||||
const ExcalidrawSetAppStateContent = React.createContext<
|
const ExcalidrawSetAppStateContext = React.createContext<
|
||||||
React.Component<any, AppState>["setState"]
|
React.Component<any, AppState>["setState"]
|
||||||
>(() => {});
|
>(() => {});
|
||||||
|
ExcalidrawSetAppStateContext.displayName = "ExcalidrawSetAppStateContext";
|
||||||
|
|
||||||
export const useExcalidrawElements = () =>
|
export const useExcalidrawElements = () =>
|
||||||
useContext(ExcalidrawElementsContext);
|
useContext(ExcalidrawElementsContext);
|
||||||
export const useExcalidrawAppState = () =>
|
export const useExcalidrawAppState = () =>
|
||||||
useContext(ExcalidrawAppStateContext);
|
useContext(ExcalidrawAppStateContext);
|
||||||
export const useExcalidrawSetAppState = () =>
|
export const useExcalidrawSetAppState = () =>
|
||||||
useContext(ExcalidrawSetAppStateContent);
|
useContext(ExcalidrawSetAppStateContext);
|
||||||
|
|
||||||
let didTapTwice: boolean = false;
|
let didTapTwice: boolean = false;
|
||||||
let tappedTwiceTimer = 0;
|
let tappedTwiceTimer = 0;
|
||||||
@ -553,7 +558,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
value={this.excalidrawContainerValue}
|
value={this.excalidrawContainerValue}
|
||||||
>
|
>
|
||||||
<DeviceContext.Provider value={this.device}>
|
<DeviceContext.Provider value={this.device}>
|
||||||
<ExcalidrawSetAppStateContent.Provider value={this.setAppState}>
|
<ExcalidrawSetAppStateContext.Provider value={this.setAppState}>
|
||||||
<ExcalidrawAppStateContext.Provider value={this.state}>
|
<ExcalidrawAppStateContext.Provider value={this.state}>
|
||||||
<ExcalidrawElementsContext.Provider
|
<ExcalidrawElementsContext.Provider
|
||||||
value={this.scene.getNonDeletedElements()}
|
value={this.scene.getNonDeletedElements()}
|
||||||
@ -619,7 +624,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
<main>{this.renderCanvas()}</main>
|
<main>{this.renderCanvas()}</main>
|
||||||
</ExcalidrawElementsContext.Provider>{" "}
|
</ExcalidrawElementsContext.Provider>{" "}
|
||||||
</ExcalidrawAppStateContext.Provider>
|
</ExcalidrawAppStateContext.Provider>
|
||||||
</ExcalidrawSetAppStateContent.Provider>
|
</ExcalidrawSetAppStateContext.Provider>
|
||||||
</DeviceContext.Provider>
|
</DeviceContext.Provider>
|
||||||
</ExcalidrawContainerContext.Provider>
|
</ExcalidrawContainerContext.Provider>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user