Help! React challenges crashing my browser

Help! React challenges crashing my browser
0

#1

I was trying out a solution for the challenge: Create a Component with Compostion, and when I tried to test it, my browser (Google Chrome) crashed. I logged back out an back in and still cannot even load the challenge now without my browser crashing. I tried a different browser (Microsoft Edge) and the solution did the same thing, except this time it slowed down my whole computer for a moment. I skipped ahead and have the same problem with: Compose React Components! Can someone tell me what I am doing wrong?

my code below for Create a Component with Composition:

 1 const ChildComponent = () => {
 2  return (
 3   <div>
 4    <p>I am the child</p>
 5   </div>
 6  );
 7 };
 8
 9 class ParentComponent extends React.Component {
10  constructor(props) {
11   super(props);
12  }
13  render() {
14   return (
15    <div>
16     <h1>I am the parent</h1>
17     { /* change code below this line */ }
18     <ParentComponent>
19       <ChildComponent />
20     </ParentComponent>
21     
22     { /* change code above this line */ }
23    </div>
24   );
25  }
26 };


#2

You’re creating an infinite tree of ParentComponents which blows up to infinity

Inside ParentComponent's render you render two more ParentComponents which each uses ParentComponent's render which renders two more Pa

I think you get where that’s going

There’s a way to clear the code by modifying the url or something but I can’t remember it offhand - it should let you break any infinite loops on the page


#3

Thanks, I get it now lol. I had to clear my cookies to get back into the challenge and then just dropped the ParentComponent tags.

I appreciate the help!

cheers