overleaf/services/web/frontend/js/features/file-tree/contexts/file-tree-main.js
Timothée Alby 420aa4a657 Merge pull request #3232 from overleaf/ta-file-tree-react
React File Tree

GitOrigin-RevId: fb3141ba8cd9ca0d68e87edb74764a360144c8fe
2020-11-27 03:05:05 +00:00

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
}