How to import and export components using React + ES6 + webpack?

后端 未结 6 1629
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 19:23

I\'m playing around with React and ES6 using babel and webpack. I want to build several components in different files, im

6条回答
  •  我在风中等你
    2020-11-28 20:06

    I Hope this is Helpfull

    Step 1: App.js is (main module) import the Login Module

    import React, { Component } from 'react';
    import './App.css';
    import Login from './login/login';
    
    class App extends Component {
      render() {
        return (
          
        );
      }
    }
    
    export default App;
    

    Step 2: Create Login Folder and create login.js file and customize your needs it automatically render to App.js Example Login.js

    import React, { Component } from 'react';
    import '../login/login.css';
    
    class Login extends Component {
      render() {
        return (
          

    Welcome to React

    To get started, edit src/App.js and save to reload.

    ); } } export default Login;

提交回复
热议问题