-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTileContext.tsx
37 lines (33 loc) · 896 Bytes
/
TileContext.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { ReactNode, createContext, useState } from "react";
import { TileType } from "../utils/types";
import {
END_TILE_CONFIGURATION,
START_TILE_CONFIGURATION,
} from "../utils/constants";
interface TileContextInterface {
startTile: TileType;
setStartTile: (startTile: TileType) => void;
endTile: TileType;
setEndTile: (endTile: TileType) => void;
}
export const TileContext = createContext<TileContextInterface | undefined>(
undefined
);
export const TileProvider = ({ children }: { children: ReactNode }) => {
const [startTile, setStartTile] = useState<TileType>(
START_TILE_CONFIGURATION
);
const [endTile, setEndTile] = useState<TileType>(END_TILE_CONFIGURATION);
return (
<TileContext.Provider
value={{
startTile,
setStartTile,
endTile,
setEndTile,
}}
>
{children}
</TileContext.Provider>
);
};