2

我运行了使用 router.create 的 react 0.13-router 但 1.0.3 它没有工作
我正在使用 router-react ,如例所示

但我有以下错误

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] } }

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

4

1 回答 1

1

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

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

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

还要记住,React Router 在其主要版本中进行了重大的重大更改。因此,您可能需要仔细查看更新日志以获取升级提示。

于 2016-01-17T06:13:58.257 回答