我是 React 初学者,我正在使用 https://jscomplete.com/repl 中的示例。
到目前为止,我的代码如下所示:
let data = [
{
name:"Paul O’Shannessy",
avatar_url:"https://avatars1.githubusercontent.com/u/8445?v=4",
company_name:"Facebook"
},
{
name:"Tom Preston-Werner",
avatar_url:"https://avatars0.githubusercontent.com/u/1?v=4",
company_name:"Facebook"
}
];
const Card = (props) => {
return (
<div style={{margin:'1em'}}>
<img width="75" src={props.avatar_url} />
<div className="info" style={{display: 'inline-block',marginLeft: 10}}>
<div style={{fontSize: '1.25em',fontWeight: 'bold'}}>{props.name}</div>
<div>{props.company_name}</div>
</div>
</div>
);
}
const CardList = (props) => {
return (
<div>
{props.cards.map((card) => <Card {...card}/>)}
</div>
);
}
class Form extends React.component {
render() {
return (
<form>
<input type="text" placeholder="Github Username" />
<button type="submit">Add Card</button>
</form>
);
};
}
class App extends React.component {
render() {
return (
<div>
<Form />
<CardList cards={data} />
</div>
);
};
}
ReactDOM.render(<App />,mountNode);
但是每次运行时,我都会收到此运行时错误。 我做错了什么?
最佳答案
应该是React.Component
而不是React.component
注意大写字母。
关于javascript - 类型错误 : Class extends value undefined is not a constructor or null in react js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48985647/