mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-01 22:41:07 -05:00
420aa4a657
React File Tree GitOrigin-RevId: fb3141ba8cd9ca0d68e87edb74764a360144c8fe
34 lines
784 B
JavaScript
34 lines
784 B
JavaScript
import React, { createContext, useState } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
|
|
export const FileTreeMainContext = createContext({})
|
|
|
|
export const FileTreeMainProvider = function({
|
|
projectId,
|
|
hasWritePermissions,
|
|
children
|
|
}) {
|
|
const [contextMenuCoords, setContextMenuCoords] = useState()
|
|
|
|
return (
|
|
<FileTreeMainContext.Provider
|
|
value={{
|
|
projectId,
|
|
hasWritePermissions,
|
|
contextMenuCoords,
|
|
setContextMenuCoords
|
|
}}
|
|
>
|
|
{children}
|
|
</FileTreeMainContext.Provider>
|
|
)
|
|
}
|
|
|
|
FileTreeMainProvider.propTypes = {
|
|
projectId: PropTypes.string.isRequired,
|
|
hasWritePermissions: PropTypes.bool.isRequired,
|
|
children: PropTypes.oneOfType([
|
|
PropTypes.arrayOf(PropTypes.node),
|
|
PropTypes.node
|
|
]).isRequired
|
|
}
|