无法解析'create-react-class'

时间:2018-04-27 16:28:01

标签: javascript json node.js

我有那些文件,我正在尝试从Data.js添加爱好并以

  • 的方式将所有爱好打印到我的App.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
    
  • 0 个答案:

    没有答案