overleaf/services/web/frontend/js/shared/context/editor-context.js
Miguel Serrano 1fcf94c3b9 Merge pull request #3436 from overleaf/msm-react-shared-context
React shared context

GitOrigin-RevId: ebc6fa90dd8c65ddf803fd457c99a30f0e8e3c9c
2020-12-15 03:05:07 +00:00

27 lines
522 B
JavaScript

import React, { createContext, useContext } from 'react'
import PropTypes from 'prop-types'
export const EditorContext = createContext()
export function EditorProvider({ children }) {
return (
<EditorContext.Provider
value={{
projectId: window.project_id
}}
>
{children}
</EditorContext.Provider>
)
}
EditorProvider.propTypes = {
children: PropTypes.any
}
export function useEditorContext() {
const { projectId } = useContext(EditorContext)
return {
projectId
}
}