Create a Component with Composition:

please could you assist …
thanks

  **Your code so far**

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 */ }
return (
    <div>
      <h1>I am the parent</h1>
      <ChildComponent />
    </div>
  );

      { /* Change code above this line */ }
    </div>
  );
}
};
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36.

Challenge: Create a Component with Composition

Link to the challenge:

Hey there,

why did you remove the Tell us what’s happening section?

Please explain why you need help.

"This is my code :- i just cant pass the challenge think i wrote the code right…

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 */ }
return (
    <div>
      <h1>I am the parent</h1>
      <ChildComponent />
    </div>
  );

      { /* Change code above this line */ }
    </div>
  );
}
};

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Hey there,

on the left side of the lesson, you can see how to return a component in another component, e.g. <Dashboard /> to return the Dashboard component.

Your task is to return the ChildComponent below the h1.
Just the ChildComponent, nothing else.


Alright Thank You :slightly_smiling_face:
Okay thank you
1 Like