Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IAugmentedJQuery, IComponentOptions } from 'angular'
import fromPairs = require('lodash.frompairs')
import NgComponent from 'ngcomponent'
import * as React from 'react'
import { render, unmountComponentAtNode } from 'react-dom'
import { render,createPortal, unmountComponentAtNode } from 'react-dom'

/**
* Wraps a React component in Angular. Returns a new Angular component.
Expand All @@ -18,7 +18,8 @@ import { render, unmountComponentAtNode } from 'react-dom'
export function react2angular<Props>(
Class: React.ComponentType<Props>,
bindingNames: (keyof Props)[] | null = null,
injectNames: string[] = []
injectNames: string[] = [],
usePortal: boolean = false
): IComponentOptions {
const names = bindingNames
|| (Class.propTypes && Object.keys(Class.propTypes) as (keyof Props)[])
Expand All @@ -41,7 +42,8 @@ export function react2angular<Props>(
}
render() {
if (!this.isDestroyed) {
render(
usePortal ? createPortal(<Class {...this.props} {...this.injectedProps as any} />,
this.$element[0]) : render(
<Class {...this.props} {...this.injectedProps as any} />,
this.$element[0]
)
Expand Down