Skip to content

Instantly share code, notes, and snippets.

@mertkahyaoglu
Created October 2, 2017 18:53
Show Gist options
  • Save mertkahyaoglu/edad56982631a291af28b7548a9aa2db to your computer and use it in GitHub Desktop.
Save mertkahyaoglu/edad56982631a291af28b7548a9aa2db to your computer and use it in GitHub Desktop.
import React, { Component } from "react";
import { render, createPortal } from "react-dom";
class List extends Component {
render() {
return [
<li key="A">First item</li>,
<li key="B">Second item</li>,
<li key="C">Third item</li>,
<OtherList />
];
}
}
class OtherList extends Component {
render() {
return createPortal(
[
<li>Fourth item</li>,
<li>Fifth item</li>
],
document.getElementById("root2"),
);
}
}
render(<List />, document.getElementById("root"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment