Jaowat Raihan
Jaowat Raihan

Reputation: 281

Failed to construct 'Comment

I am new to React. I want to print out an array of objects in the view.

In my render() method of App component, I tried this:

render() {
return (
  <div>
       Your data:
       {
         this.props.val.map(
           (s, i) => 
              <Details key={i} data={s} />
          )
       }
  </div>
);
} 

And In Details Component:

class Details extends Comment{
rendeer(){
return (
  <div>
     <span>{this.props.data.name} {this.props.data.cgpa}</span> 
  </div>
);
}};

Note: Both the components are in the same file. And i am facing this error=> ErroMessage

But if i do this instead of calling details component:

Your data:<br />
       {
         this.props.val.map(
           (s, i) => 
           <p key={i}>{s.name} {s.cgpa}</p> 
          )
       }

It works perfectly fine.

Upvotes: 1

Views: 30

Answers (1)

Arup Rakshit
Arup Rakshit

Reputation: 118299

You have a typo rendeer(). It should be render().

I think you mistyped Comment, it should be Component. Like :

import React, {Component} from react;

class Details extends Component {
  // ...
}

Upvotes: 4

Related Questions