Skip to content

Commit 9471b03

Browse files
committed
feat(providers): Add Encrypted from cozy-viewer
and remove it from there
1 parent 9f9fbb9 commit 9471b03

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React, { useContext } from 'react'
2+
3+
export const EncryptedContext = React.createContext()
4+
5+
export const useEncrypted = () => {
6+
const context = useContext(EncryptedContext)
7+
8+
if (!context) {
9+
throw new Error('useEncrypted must be used within a EncryptedProvider')
10+
}
11+
return context
12+
}
13+
14+
const EncryptedProvider = ({ url, children }) => {
15+
const contextValue = {
16+
url
17+
}
18+
return (
19+
<EncryptedContext.Provider value={contextValue}>
20+
{children}
21+
</EncryptedContext.Provider>
22+
)
23+
}
24+
25+
export default React.memo(EncryptedProvider)

0 commit comments

Comments
 (0)