Skip to content

Commit 7d6d366

Browse files
authored
Merge pull request #187 from ZhiliangLiu/zoranliu/fix-react-fragment
fix react fragment
2 parents d77059f + d0b2db4 commit 7d6d366

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

libs/core/src/lib/renderer/components/Disguise.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export interface DisguiseProps {
2929
* The Angular child components to render.
3030
*/
3131
ngChildComponents?: ReactWrapperComponent<any>[];
32+
33+
key?: string | number
3234
}
3335

3436
/**
@@ -37,15 +39,18 @@ export interface DisguiseProps {
3739
export class Disguise extends React.PureComponent<DisguiseProps> {
3840
render() {
3941
const { disguiseRootAs, disguiseChildrenAs, children, ngChildComponents, ...rest } = this.props;
40-
const Root = disguiseRootAs || React.Fragment;
4142

4243
const renderedChildren = ngChildComponents
4344
? this._isReactContentOnlyChild()
4445
? this._renderReactContentChildren()
4546
: this._renderChildrenNaive()
4647
: children;
4748

48-
return React.createElement(Root, rest || null, renderedChildren);
49+
if (disguiseRootAs != null) {
50+
return React.createElement(disguiseRootAs, rest || null, renderedChildren);
51+
} else {
52+
return React.createElement(React.Fragment, rest.key != null ? { key: rest.key } : null, renderedChildren);
53+
}
4954
}
5055

5156
private _isReactContentOnlyChild(): boolean {

0 commit comments

Comments
 (0)