Skip to content

Instantly share code, notes, and snippets.

@colinfwren
Created September 28, 2021 20:41
Show Gist options
  • Save colinfwren/a0203979d54efa3771a38fefba32be24 to your computer and use it in GitHub Desktop.
Save colinfwren/a0203979d54efa3771a38fefba32be24 to your computer and use it in GitHub Desktop.
ViewBox Context
import { createContext } from 'react';
const ViewBoxContext = createContext({
xPos: 75,
setXPos: () => null,
yPos: 75,
setYPos: () => null,
scale: 1,
setScale: () => null,
scaleDelta: 0,
setScaleDelta: () => null,
miniMapX: 75,
setMiniMapX: () => null,
miniMapY: 75,
setMiniMapY: () => null,
});
const { Provider } = ViewBoxContext;
export function ViewBoxProvider({ children, value}) {
return <Provider value={value}>{children}</Provider>
}
export const ViewBoxConsumer = ViewBoxContext.Consumer;
export default ViewBoxContext;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment