警告:失败的道具类型:提供给`Route`的无效道具`组件`。在路线

时间:2017-05-24 15:38:05

标签: javascript reactjs react-router

我已经对这个错误的所有答案进行了大约一个星期的讨论。我似乎无法摆脱这个错误。任何帮助将是超级有用的和赞赏。

import React from "react";
import ReactDOM from "react-dom";
import ReactRouter, {
    Router,
    Route,
    IndexRoute,
    IndexLink,
    Link,
    hashHistory
} from "react-router";

import Home from "./home";
import Lists from "./lists";
import Mailings from "./mailings";
import App from "./app";
import Templates from "./templates";
import subCategorypage from "./subcategoryrepeat";
import Members from "./members";
import Assets from "./assets";
import ImportList from "./importlist";
import MailingWizard from "./mailingwizardone";
import DealerProfile from "./dealerprofile";
import UserProfile from "./userprofile";
import ApiKey from "./apikey";
import Login from "./login";
import NewMember from "./newMemberSlide"
import ImportTemplate from "./importTemplate";
import ImportAsset from "./importAsset";
import Register from "./register";
import FileMap from "./filemap";
import Invite from "./invite";
import MaterialUIAutocomplete from "./searchpiece";
import Example from "./autosuggest";
import NewForm from "./newmemberform";
import SignInForm from "./registrationform";


    var destination = document.querySelector("#container");

    ReactDOM.render(
        <Router history={hashHistory}>
            <Route path="/" component={App}>
                <IndexRoute component={Home}/>
                <Route path="lists" component={Lists}/>
                <Route path="mailings" component={Mailings}/>
                <Route path="templates" component={Templates} />
                <Route path="subcategoryrepeat/:subcategoryId" component={subCategorypage}/>
                <Route path="members" component={Members}/>
                <Route path="assets" component={Assets}/>
                <Route path="importlist" component={ImportList}/>
                <Route path="mailingwizardone" component={MailingWizard}/>
                <Route path="dealerprofile" component={DealerProfile}/>
                <Route path="userprofile" component={UserProfile}/>
                <Route path="apikey" component={ApiKey}/>
                <Route path="login" component={Login}/>
                <Route path="newMemberSlide" component={NewMember}/>
                <Route path="importTemplate" component={ImportTemplate}/>
                <Route path="importAsset" component={ImportAsset}/>
                <Route path="register" component={Register}/>
                <Route path="filemap" component={FileMap}/>
                <Route path="invite" component={Invite}/>
                <Route path="searchpiece" component={MaterialUIAutocomplete}/>
                <Route path="autosuggest" component={Example}/>
                <Route path="newmemberform" component={NewForm}/>
                <Route path="registrationform" component={SignInForm}/>



            </Route>
        </Router>,
        destination
    );

根据我看到的所有内容看起来代码都是正确的,但错误仍在发生。我在两个操作系统和两个浏览器上试过它。

1 个答案:

答案 0 :(得分:0)

这个错误今天刚好发生在我身上,我看到这个问题自去年发布以来没有进一步的想法,所以也许这会帮助别人。我想知道这张海报是否有同样的问题,因为他们有很长的路线和进口清单,也许还有一些在某种程度上尚未完成。

如果您尚未开发那么长的导入组件列表,并且某些导入的文件仍然是空白或缺少React代码的基本部分,我发现它可能导致不同的“无效道具”错误('组件' ','渲染'等。)

如果这是问题,请注释掉那些尚未开发的文件的行,直到它们准备就绪,修复错误。也就是说,它使您仍然可以在浏览器中加载文件,而不是让它在您要导入的不完整文件时出错。

例如,如果“dealerprofile”组件是空白文件仍然或仅部分写入,如果您注释掉dealerprofile的导入行和dealerprofile的行,这可能会修复错误,那么您可以简单地取消注释这些行一旦这些文件更充分地开发自己。