Cant Compile Lesson

I’m trying to run React lesson 9 in the Front End Development curriculum (Front End Development Libraries/React/ Create a Component with Composition). But for some reason, it does not compile and starts chugging ram. To be specific it takes up to 16GB of RAM while trying to compile. This is the only tab open in Firefox and I have no other things which are competing for RAM. Is this a server problem? or what could be the reason for this abnormal behaviour? I have just recently completed all lessons previous to this one without issues.

Please Help!

Probably going to need to show us your code.

const ChildComponent = () => {

  return (

    <div>

      <p>I am the child</p>

    </div>

  );

};

class ParentComponent extends React.Component {

  constructor(props) {

    super(props);

  }

  render() {

    return (

      <div>

        <h1>I am the parent</h1>

        { /* Change code below this line */ }

        <ParentComponent>

          <ChildComponent/>

        </ParentComponent>

        { /* Change code above this line */ }

      </div>

    );

  }

};

Something tells me you don’t want to create a ParentComponent from within the ParentComponent render function. Seems like you are just going to keep creating ParentComponents over and over again until you run out of memory or your browser feels sorry for you and mercifully stops the execution :slight_smile:

To be a little more clear, when you create a ParentComponent it automatically calls the render function, so you can see that if you create a ParentComponent in the render function of the ParentComponent itself you have basically created a non-stop chain of creating ParentComponents because each render is going to create a new one.

I’m not a React expert so I might not have all the terminology above correct but I’m pretty sure that’s why you are running out of memory.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.