奇怪的错误与console.log定义未定义组件的反应

时间:2017-05-06 13:36:17

标签: javascript reactjs typescript

我在我的主要应用程序中使用此代码:

import * as React from 'react';
import { render } from "react-dom";
import { Provider } from 'react-redux';
import * as Redux from 'redux';
import { CompactdState } from 'definitions';
import { Route } from 'react-router-dom';
import { ConnectedRouter } from 'react-router-redux';
import { history } from './CompactdStore';
import AppView from 'features/app/components/AppView';
import {ArtistsView} from 'features/library/components/ArtistsView';
import {HolisticView} from 'features/library/components/HolisticView';
import LibraryView from 'features/library/components/LibraryView';

interface CompactdApplicationProps {
  store: Redux.Store<CompactdState>;
}
export class CompactdApplication extends
  React.Component<CompactdApplicationProps, {}> {

  render (): JSX.Element {
    console.log(Route, LibraryView, HolisticView); // <---
    return <Provider store={this.props.store}>
      <ConnectedRouter history={history}>
        <div>
          <AppView {...this.props as any}>
            <Route path="/library/:artist?" children={(props: any) =>
              <LibraryView component={HolisticView} {...props}/>} />
          </AppView>
        </div>
      </ConnectedRouter>
    </Provider>;
  }
}

真正奇怪的是,当我删除console.log时,Route,LibraryView和HolisticView未定义。

知道为什么吗?

0 个答案:

没有答案