组件未定义的反应路由器

时间:2016-01-17 02:34:13

标签: express reactjs react-router react-dom

我运行了反应0.13路由器,它使用router.create但是1.0.3 它没有工作 我在this示例

中使用路由器反应

但我有以下错误

Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).
{ [Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.] name: 'Invariant Violation', framesToPop: 1 }

这是向我显示renderProps的日志

{ routes: 
   [ { childRoutes: [Object] },
     { path: '/',
       component: [Function: BaseAdmin],
       indexRoute: [Object],
       childRoutes: [Object] },
     { component: [Function: Home] } ],
  params: {},
  location: 
   { pathname: '/',
     search: '',
     hash: '',
     state: null,
     action: 'POP',
     key: 'zljum4',
     query: {},
     '$searchBase': { search: '', searchBase: '' } },
  components: [ undefined, [Function: BaseAdmin], [Function: Home] ],
  history: 
   { listenBefore: [Function: listenBefore],
     listen: [Function: listen],
     transitionTo: [Function: transitionTo],
     push: [Function: push],
     replace: [Function: replace],
     go: [Function: go],
     goBack: [Function: goBack],
     goForward: [Function: goForward],
     createKey: [Function: createKey],
     createPath: [Function: createPath],
     createHref: [Function: createHref],
     createLocation: [Function: createLocation],
     setState: [Function: setState],
     registerTransitionHook: [Function: registerTransitionHook],
     unregisterTransitionHook: [Function: unregisterTransitionHook],
     pushState: [Function: pushState],
     replaceState: [Function: replaceState],
     isActive: [Function: isActive],
     match: [Function: match],
     listenBeforeLeavingRoute: [Function: listenBeforeLeavingRoute] } }

请使用一些简单的例子吗?

1 个答案:

答案 0 :(得分:1)

看起来你的问题来自这条线:

components: [ undefined, [Function: BaseAdmin], [Function: Home] ],
//            ^^^^^^^^^

看起来它应该是一个组件。

另请注意,React Router在其主要版本中进行了重大改变。因此,您可能需要仔细查看changelog的升级提示。

相关问题