Skip to content

Commit

Permalink
feat(providers): Add Encrypted from cozy-viewer
Browse files Browse the repository at this point in the history
and remove it from there
  • Loading branch information
JF-Cozy committed Oct 24, 2024
1 parent 9f9fbb9 commit 9471b03
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions react/providers/Encrypted/index.jsx
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)

0 comments on commit 9471b03

Please sign in to comment.