1

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.

1
  • Where did you define Comment class? Shouldn't it be Component instead? Commented Apr 7, 2018 at 14:59

1 Answer 1

4

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 { // ... } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.