feat: update jotai (#9015)
* feat: update jotai in excalidraw package * feat: update jotai in excalidraw-app * fix: exports from excalidraw/jotai * fix: use isolated react hooks * test: use jotai provider in <Trans /> test * remove unused package * refactor & make safer --------- Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import React from "react";
|
||||
import tunnel from "tunnel-rat";
|
||||
import { createIsolation } from "jotai-scope";
|
||||
|
||||
export type Tunnel = ReturnType<typeof tunnel>;
|
||||
|
||||
@@ -14,13 +15,17 @@ type TunnelsContextValue = {
|
||||
DefaultSidebarTabTriggersTunnel: Tunnel;
|
||||
OverwriteConfirmDialogTunnel: Tunnel;
|
||||
TTDDialogTriggerTunnel: Tunnel;
|
||||
jotaiScope: symbol;
|
||||
// this can be removed once we create jotai stores per each editor
|
||||
// instance
|
||||
tunnelsJotai: ReturnType<typeof createIsolation>;
|
||||
};
|
||||
|
||||
export const TunnelsContext = React.createContext<TunnelsContextValue>(null!);
|
||||
|
||||
export const useTunnels = () => React.useContext(TunnelsContext);
|
||||
|
||||
const tunnelsJotai = createIsolation();
|
||||
|
||||
export const useInitializeTunnels = () => {
|
||||
return React.useMemo((): TunnelsContextValue => {
|
||||
return {
|
||||
@@ -34,7 +39,7 @@ export const useInitializeTunnels = () => {
|
||||
DefaultSidebarTabTriggersTunnel: tunnel(),
|
||||
OverwriteConfirmDialogTunnel: tunnel(),
|
||||
TTDDialogTriggerTunnel: tunnel(),
|
||||
jotaiScope: Symbol(),
|
||||
tunnelsJotai,
|
||||
};
|
||||
}, []);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user