我有那些文件,我正在尝试从Data.js添加爱好并以
create-react-class
未找到的错误,
有谁知道如何解决它?
App.js
import React, { Component } from 'react';
import Projects from './Components/Projects';
import './App.css';
import Data from './Data.js';
import Profile from './Components/profile';
import Hobbies from './Components/hobbies';
class App extends Component {
render() {
return (
<div className="App">
<Profile name={this.props.profileData.name}imgUrl={this.props.profileData.imgURL} />
<Hobbies hobbyList={this.props.profileData.hobbyList}/>
<h3 > My Hobbies : </h3>
</div>
);
}
}
export default App;
Hobbies.js
import React, {Component} from 'react';
var createReactClass = require('create-react-class');
var Hobbies = createReactClass({
render: function(){
var hobbies = this.props.hobbyList.map(function(hobby, index){
return (<li key={index}>{hobby}</li>);
});
return (
<div>
<h5>My hobbies:</h5>
<ul>
{hobbies}
</ul>
</div>
);
}
});
export default Hobbies;
Profile.js
import React from 'react';
var createReactClass = require('create-react-class');
var Profile = createReactClass({
render: function(){
return (
<div>
<h3>{this.props.name}</h3>
<img src={this.props.imgUrl} />
</div>
)
}
});
export default Profile
Data.js
var data={
name:'it's me',
imgURL: 'me',
hobboyList:
[
'diving',
'soccer',
'sleep'
]
}
export default data