slinky icon indicating copy to clipboard operation
slinky copied to clipboard

Support the magical 3rd argument for React createPortal

Open evbo opened this issue 2 years ago • 0 comments

There is a hidden optional 3rd argument to createPortal Slinky forgot to include:

https://github.com/facebook/react/issues/12247#issuecomment-376840625

Totally undocumented and doesn't matter until you hit the edge case discussed in there :)

Should be:

@js.native
@JSImport("react-dom", JSImport.Namespace, "ReactDOM")
object ReactDOM extends js.Object {
  def render(component: ReactElement, target: Element): ReactInstance  = js.native
  def hydrate(component: ReactElement, target: Element): ReactInstance = js.native
  def findDOMNode(instance: React.Component): Element                  = js.native

  def unmountComponentAtNode(container: Element): Unit = js.native

  def createPortal(child: ReactElement, container: Element, key: js.UndefOr[String] = js.undefined): ReactElement = js.native
}

evbo avatar Apr 27 '22 18:04 evbo