-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
photo state gets updated but isnt displayed correctly for some reason…
…. TODO: Fix
- Loading branch information
Teun van Dalen
committed
Dec 4, 2023
1 parent
6a101ce
commit ec342ec
Showing
10 changed files
with
82 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { Dispatch, SetStateAction, createContext, useContext, useState } from 'react'; | ||
|
||
type ImagesContextType = { | ||
photos: { [k: string]: ArrayBuffer }; | ||
setPhotos: Dispatch<SetStateAction<{ [k: string]: ArrayBuffer }>>; | ||
}; | ||
|
||
const ImagesContext = createContext<ImagesContextType | undefined>(undefined); | ||
|
||
export const ImageProvider: React.FC<React.PropsWithChildren<{}>> = ({ children }) => { | ||
const [photos, setPhotos] = useState<{ [k: string]: ArrayBuffer }>({}); | ||
|
||
return ( | ||
<ImagesContext.Provider value={{ photos, setPhotos }}> | ||
{children} | ||
</ImagesContext.Provider> | ||
); | ||
}; | ||
|
||
export const useImagesContext = () => { | ||
const context = useContext(ImagesContext); | ||
if (!context) { | ||
throw new Error('useImages must be used within a ImageProvider'); | ||
} | ||
return context; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters