editor-context.js 522 B

123456789101112131415161718192021222324252627
  1. import React, { createContext, useContext } from 'react'
  2. import PropTypes from 'prop-types'
  3. export const EditorContext = createContext()
  4. export function EditorProvider({ children }) {
  5. return (
  6. <EditorContext.Provider
  7. value={{
  8. projectId: window.project_id
  9. }}
  10. >
  11. {children}
  12. </EditorContext.Provider>
  13. )
  14. }
  15. EditorProvider.propTypes = {
  16. children: PropTypes.any
  17. }
  18. export function useEditorContext() {
  19. const { projectId } = useContext(EditorContext)
  20. return {
  21. projectId
  22. }
  23. }