Grabbed dndbeyond's source code
``` ~/go/bin/sourcemapper -output ddb -jsurl https://media.dndbeyond.com/character-app/static/js/main.90aa78c5.js ```
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import React, { useContext, useMemo } from "react";
|
||||
|
||||
import { InventoryManager } from "@dndbeyond/character-rules-engine/es";
|
||||
|
||||
interface InventoryManagerContextValue {
|
||||
inventoryManager: InventoryManager;
|
||||
}
|
||||
const initContext: InventoryManagerContextValue = {
|
||||
inventoryManager: new InventoryManager(),
|
||||
};
|
||||
export const InventoryManagerContext =
|
||||
React.createContext<InventoryManagerContextValue>(initContext);
|
||||
|
||||
export function InventoryManagerProvider({ children }) {
|
||||
const inventoryManager: InventoryManager = useMemo(
|
||||
() => new InventoryManager(),
|
||||
[]
|
||||
);
|
||||
return (
|
||||
<InventoryManagerContext.Provider value={{ inventoryManager }}>
|
||||
{children}
|
||||
</InventoryManagerContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export const useInventoryManager = () => {
|
||||
return useContext(InventoryManagerContext);
|
||||
};
|
||||
Reference in New Issue
Block a user