MCPcopy Create free account
hub / github.com/testing-library/react-testing-library / MyPortal

Class MyPortal

src/__tests__/render.js:35–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34 test('works great with react portals', () => {
35 class MyPortal extends React.Component {
36 constructor(...args) {
37 super(...args)
38 this.portalNode = document.createElement('div')
39 this.portalNode.dataset.testid = 'my-portal'
40 }
41 componentDidMount() {
42 document.body.appendChild(this.portalNode)
43 }
44 componentWillUnmount() {
45 this.portalNode.parentNode.removeChild(this.portalNode)
46 }
47 render() {
48 return ReactDOM.createPortal(
49 <Greet greeting="Hello" subject="World" />,
50 this.portalNode,
51 )
52 }
53 }
54
55 function Greet({greeting, subject}) {
56 return (

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…