Link组件报错

来源:13-3 注册功能模块设计(下)

慕无忌0079048

2017-12-11

<Link target="_blank">

<Button type="dashed" htmlType="button">个人中心</Button>

 </Link>

把上面的代码摘掉就不报错,版本:

"react-router": "^4.2.0",

"react-router-dom": "^4.2.2",



报错内容为:

bundle.js:15572 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.


Check the render method of `PCHeader`.

    in PCHeader (created by Form(PCHeader))

    in Form(PCHeader) (created by PCIndex)

    in div (created by PCIndex)

    in PCIndex (created by Root)

    in MediaQuery (created by Root)

    in div (created by Root)

    in Root

printWarning @ bundle.js:15572

warning @ bundle.js:15596

createElementWithValidation @ bundle.js:47984

render @ bundle.js:68400

finishClassComponent @ bundle.js:56271

updateClassComponent @ bundle.js:56248

beginWork @ bundle.js:56623

performUnitOfWork @ bundle.js:58622

workLoop @ bundle.js:58686

callCallback @ bundle.js:48940

invokeGuardedCallbackDev @ bundle.js:48979

invokeGuardedCallback @ bundle.js:48836

renderRoot @ bundle.js:58764

performWorkOnRoot @ bundle.js:59412

performWork @ bundle.js:59365

batchedUpdates @ bundle.js:59484

batchedUpdates @ bundle.js:50728

dispatchEvent @ bundle.js:51819

bundle.js:5144 Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.


Check the render method of `PCHeader`.

    at invariant (bundle.js:5144)

    at createFiberFromElement (bundle.js:54151)

    at createChild (bundle.js:55374)

    at reconcileChildrenArray (bundle.js:55680)

    at reconcileChildFibers (bundle.js:56049)

    at reconcileChildrenAtExpirationTime (bundle.js:56154)

    at reconcileChildren (bundle.js:56145)

    at updateHostComponent (bundle.js:56396)

    at beginWork (bundle.js:56627)

    at performUnitOfWork (bundle.js:58622)

invariant @ bundle.js:5144

createFiberFromElement @ bundle.js:54151

createChild @ bundle.js:55374

reconcileChildrenArray @ bundle.js:55680

reconcileChildFibers @ bundle.js:56049

reconcileChildrenAtExpirationTime @ bundle.js:56154

reconcileChildren @ bundle.js:56145

updateHostComponent @ bundle.js:56396

beginWork @ bundle.js:56627

performUnitOfWork @ bundle.js:58622

workLoop @ bundle.js:58686

callCallback @ bundle.js:48940

invokeGuardedCallbackDev @ bundle.js:48979

invokeGuardedCallback @ bundle.js:48836

renderRoot @ bundle.js:58764

performWorkOnRoot @ bundle.js:59412

performWork @ bundle.js:59365

batchedUpdates @ bundle.js:59484

batchedUpdates @ bundle.js:50728

dispatchEvent @ bundle.js:51819

bundle.js:58145 The above error occurred in the <li> component:

    in li (created by MenuItem)

    in MenuItem (created by MenuItem)

    in Trigger (created by Tooltip)

    in Tooltip (created by Tooltip)

    in Tooltip (created by MenuItem)

    in MenuItem (created by Menu)

    in ul (created by DOMWrap)

    in DOMWrap (created by Menu)

    in Menu (created by Menu)

    in Menu (created by PCHeader)

    in div (created by Col)

    in Col (created by PCHeader)

    in div (created by Row)

    in Row (created by PCHeader)

    in header (created by PCHeader)

    in PCHeader (created by Form(PCHeader))

    in Form(PCHeader) (created by PCIndex)

    in div (created by PCIndex)

    in PCIndex (created by Root)

    in MediaQuery (created by Root)

    in div (created by Root)

    in Root


Consider adding an error boundary to your tree to customize error handling behavior.

Visit https://fb.me/react-error-boundaries to learn more about error boundaries.

logCapturedError @ bundle.js:58145

captureError @ bundle.js:58938

renderRoot @ bundle.js:58789

performWorkOnRoot @ bundle.js:59412

performWork @ bundle.js:59365

batchedUpdates @ bundle.js:59484

batchedUpdates @ bundle.js:50728

dispatchEvent @ bundle.js:51819

bundle.js:5144 Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.


Check the render method of `PCHeader`.

    at invariant (bundle.js:5144)

    at createFiberFromElement (bundle.js:54151)

    at createChild (bundle.js:55374)

    at reconcileChildrenArray (bundle.js:55680)

    at reconcileChildFibers (bundle.js:56049)

    at reconcileChildrenAtExpirationTime (bundle.js:56154)

    at reconcileChildren (bundle.js:56145)

    at updateHostComponent (bundle.js:56396)

    at beginWork (bundle.js:56627)

    at performUnitOfWork (bundle.js:58622)

invariant @ bundle.js:5144

createFiberFromElement @ bundle.js:54151

createChild @ bundle.js:55374

reconcileChildrenArray @ bundle.js:55680

reconcileChildFibers @ bundle.js:56049

reconcileChildrenAtExpirationTime @ bundle.js:56154

reconcileChildren @ bundle.js:56145

updateHostComponent @ bundle.js:56396

beginWork @ bundle.js:56627

performUnitOfWork @ bundle.js:58622

workLoop @ bundle.js:58686

callCallback @ bundle.js:48940

invokeGuardedCallbackDev @ bundle.js:48979

invokeGuardedCallback @ bundle.js:48836

renderRoot @ bundle.js:58764

performWorkOnRoot @ bundle.js:59412

performWork @ bundle.js:59365

batchedUpdates @ bundle.js:59484

batchedUpdates @ bundle.js:50728

dispatchEvent @ bundle.js:51819

bundle.js:15572 Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op.


Please check the code for the PCHeader component.



写回答

1回答

Parry

2017-12-11

你 link 的导入是怎么导入的?

import {Link} from 'react-router-dom';

0
1
慕无忌0079048
非常感谢!
2017-12-11
共1条回复

结合基础与实战学习React.js 独立开发新闻头条平台

轻松入门 React 开发,React Router 4 与 Webpack 2 完美升级项目

2768 学习 · 2126 问题

查看课程