2016-08-20 2 views
0

간단한 프로젝트를 ES5에서 ES6, 7로 변환했지만 문제가 발생했습니다. . enter image description hereUncaught TypeError : 슈퍼식이 null이거나 함수가 아닌 정의되지 않은 함수 여야합니다. (React.js, Flux, ES6)

내가 공통의 일부 수정을 검토 한 결과 : : 내 index.html을 열 때 나는이 오류가

  • 업데이트

(15 더 전체 ES6 지원을해야한다 반작용 없다 ?)

enter image description here

  • 맞춤법 오류에 수입 또는 원형 의존성

resultConstants.js

export const RESULTS = { 
    RECEIVED_SEARCH: "RECEIVED_SEARCH", 
    RECEIVED_RESULTS: "RECEIVED_RESULTS" 
}; 

dispatcher.js

import { Dispatcher } from 'flux'; 

const AppDispatcher = new Dispatcher(); 

export default AppDispatcher; 

하지만 난 정말 아직도 문제를 확인할 수 없습니다. 여기에 문제를 일으키는 상점이 있습니다.

constructor() { 
    super(); 
} 

여전히이 오류와 함께 온다 : 나는이 코드 조각을 포함 할 경우에도

import AppDispatcher from '../dispatcher/dispatcher'; 
import { RESULTS } from '../constants/resultConstants'; 
import { FluxStore } from 'flux'; 

let _query = 'restaurant', 
    _results = []; 

const _mapOptions = { 
    ... 
}; 

class ResultStore extends FluxStore { 
    query() { 
    return _query; 
    } 

    mapOptions() { 
    return _mapOptions; 
    } 

    all() { 
    return _results.slice(0, 9); 
    } 

    __onDispatch(payload) { 
    switch(payload.type) { 
     case RESULTS.RECEIVED_SEARCH: 
     _resetQuery(payload.search.query) 
     _resetCenter(payload.search.center); 
     resultStore.__emitChange(); 
     break; 
     case RESULTS.RECEIVED_RESULTS: 
     _resetResults(payload.results); 
     resultStore.__emitChange(); 
     break; 
     default: 
     return; 
    } 
    } 
} 

function _resetQuery (query) { 
    _query = query; 
} 

function _resetCenter (center) { 
    _mapOptions.center = center; 
}; 

function _resetResults (results) { 
    _results = results; 
}; 

export const resultStore = new ResultStore(AppDispatcher); 

은 명확합니다.

질문

  1. 이 오류가 나타납니다 왜 어떤 다른 이유는 무엇입니까?
  2. 내 ES6은 어떻습니까? (건설적인 비판은 인정됩니다)
+0

확인 다른 가능한 문제에 대한이 질문에 (확장 클래스를 확장 한 클래스 아래에 작성해야합니다) 일반적으로 발생/typos : http://stackoverflow.com/questions/30116430/reactjs-giving-error-uncaught-typeerror-super-expression-must-either-be-null-or?rq=1 – Jecoms

+0

'FluxStore'가 존재합니까? ? 만약 당신이'log'한다면, 당신은'undefined'를 얻을 것이라고 확신합니다. – loganfsmyth

답변

0

분명히 존재하지 않는 클래스에서 클래스를 확장하면 오류가 없습니다. 따라서 super가 호출되었지만 부모가없는 경우이 오류가 발생합니다. Uncaught TypeError : Super식이 null이거나 정의되지 않은 함수 여야합니다.

중 하나 순서로 인해 오타 또는 인해 중, 당신은 확실히 부하를하지 않았다 클래스를 확장하여