복붙노트

[REACTJS] ReactJS에서 내보내기 (기본값) 클래스

REACTJS

ReactJS에서 내보내기 (기본값) 클래스

해결법


  1. 1.안녕과 반작용에 오신 것을 환영합니다!

    안녕과 반작용에 오신 것을 환영합니다!

    난 당신이 여기에 문제가있어 어떤 부분이 정말 반작용 별, 대신 새로운 ES2015 모듈 구문과 관련이없는 생각합니다. 클래스의 구성 요소에 반응 만들 때, 대부분의 의도와 목적을 위해 당신은 클래스를 MyComponent이 React.Component 확장에 기능적으로 동등하게 React.createClass 생각할 수 있습니다. 다른 하나는 사전 ES2015 구문을 사용하는 반면, 하나는 새로운 ES2015 클래스 구문을 사용하고 있습니다.

    모듈에 대한 학습을 ​​위해, 나는 잘 알고 얻을 수있는 새로운 모듈 구문에 대한 몇 가지 기사를 읽어 보시기 바랍니다 것입니다. http://www.2ality.com/2014/09/es6-modules-final.html : 여기에서 시작하는 좋은 하나입니다.

    그래서 짧은에,이 구문 단지 차이점은,하지만 난 빠른 워크를 통해 작업을 수행하려고 할 것입니다 :

    /**
     * This is how you import stuff.  In this case you're actually 
     * importing two things:  React itself and just the "Component" 
     * part from React.  Importing the "Component" part by itself makes it
     * so that you can do something like:
     *
     * class MyComponent extends Component ...
     * 
     * instead of...
     * 
     * class MyComponent extends React.Component
     * 
     * Also note the comma below
     */
    import React, {Component} from 'react';
    
    
    /**
     * This is a "default" export.  That means when you import 
     * this module you can do so without needing a specific module
     * name or brackets, e.g.
     * 
     * import Header from './header';
     *
     * instead of...
     *
     * import { Header } from './header';
     */
    export default class Header extends Component {
    
    }
    
    /**
     * This is a named export.  That means you must explicitly
     * import "Header" when importing this module, e.g.
     *
     * import { Header } from './header';
     *
     * instead of...
     * 
     * import Header from './header';
     */
    export const Header = React.createClass({
    
    })
    
    /**
     * This is another "default" export, only just with a 
     * little more shorthand syntax.  It'd be functionally 
     * equivalent to doing:
     *
     * const MyClass = React.createClass({ ... });
     * export default MyClass;
     */
    export default React.createClass({
    
    })
    
  2. from https://stackoverflow.com/questions/34840708/export-default-class-in-reactjs by cc-by-sa and MIT license