-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(providers): Add Encrypted from cozy-viewer
and remove it from there
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { useContext } from 'react' | ||
|
||
export const EncryptedContext = React.createContext() | ||
|
||
export const useEncrypted = () => { | ||
const context = useContext(EncryptedContext) | ||
|
||
if (!context) { | ||
throw new Error('useEncrypted must be used within a EncryptedProvider') | ||
} | ||
return context | ||
} | ||
|
||
const EncryptedProvider = ({ url, children }) => { | ||
const contextValue = { | ||
url | ||
} | ||
return ( | ||
<EncryptedContext.Provider value={contextValue}> | ||
{children} | ||
</EncryptedContext.Provider> | ||
) | ||
} | ||
|
||
export default React.memo(EncryptedProvider) |