Skip to content

Commit

Permalink
[components] Work around tsconfig issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard authored and rexxars committed Oct 6, 2020
1 parent 2abe8fa commit 573152b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 1 addition & 12 deletions packages/@sanity/components/src/portal/context.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import {createContext} from 'react'
import {defaultContextValue} from './defaultContextValue'

export interface PortalContextInterface {
element: HTMLElement
}

let globalElement: HTMLDivElement | null = null

const defaultContextValue = {
get element() {
if (globalElement) return globalElement
globalElement = document.createElement('div')
globalElement.setAttribute('data-portal', 'default')
document.body.appendChild(globalElement)
return globalElement
}
}

export const PortalContext = createContext<PortalContextInterface>(defaultContextValue)
13 changes: 13 additions & 0 deletions packages/@sanity/components/src/portal/defaultContextValue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let globalElement = null

export const defaultContextValue = {
get element() {
if (globalElement) return globalElement

globalElement = document.createElement('div')
globalElement.setAttribute('data-portal', 'default')
document.body.appendChild(globalElement)

return globalElement
}
}

0 comments on commit 573152b

Please sign in to comment.