Ad
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=>
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.
Ad
Answer
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 {
// ...
}
Ad
source: stackoverflow.com
Related Questions
- → Import statement and Babel
- → should I choose reactjs+f7 or f7+vue.js?
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → .tsx webpack compile fails: Unexpected token <
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → React Native with visual studio 2015 IDE
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
- → How do I determine if a new ReactJS session and/or Browser session has started?
- → Alt @decorators in React-Native
- → How to dynamically add class to parent div of focused input field?
Ad