mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-05 09:52:12 +00:00
28 lines
536 B
JavaScript
28 lines
536 B
JavaScript
|
import React, { createContext, useContext } from 'react'
|
||
|
import PropTypes from 'prop-types'
|
||
|
|
||
|
export const ApplicationContext = createContext()
|
||
|
|
||
|
export function ApplicationProvider({ children }) {
|
||
|
return (
|
||
|
<ApplicationContext.Provider
|
||
|
value={{
|
||
|
user: window.user
|
||
|
}}
|
||
|
>
|
||
|
{children}
|
||
|
</ApplicationContext.Provider>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
ApplicationProvider.propTypes = {
|
||
|
children: PropTypes.any
|
||
|
}
|
||
|
|
||
|
export function useApplicationContext() {
|
||
|
const { user } = useContext(ApplicationContext)
|
||
|
return {
|
||
|
user
|
||
|
}
|
||
|
}
|