简体   繁体   English

反应路由器白屏

[英]React Router White Screen

Using a similar React-Route from a previous project that worked but this one just gives a white screen, if i make a nav link in the root directory it changes the path but stays white. 使用上一个有效的先前项目的类似React-Route,但这个项目只是显示白屏,如果我在根目录中创建导航链接,它将更改路径,但保持白色。 not sure why the content is not loading in. also have the code on repo: repo with code 不确定为什么不加载内容。repo上也有代码: repo with code

index.js index.js

import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, browserHistory, IndexRoute } from 'react-router';

import App from './App';
import Test from './components/test';
import Home from './pages/home_page';
import './index.css';

ReactDOM.render((
  <Router history={browserHistory}>
    <Route path='/' component={App}>
      <IndexRoute component={Home}/>
      <Route path='/test' component={Test} />
    </Route>
  </Router>
), document.getElementById('app'))

App.js App.js

import React, { Component } from 'react';
import './App.css';

export default class App extends Component {
  render() {
    return (
      <div>
       {this.props.childen}
      </div>
    );
  }
}

Just adding that the console has no errors and says it was compiled correctly with no warnings. 仅添加控制台没有错误,并说它已正确编译,没有警告。 The url does change but the content is not loaded to the page. 网址确实会更改,但是内容未加载到页面。

I cloned your repo and discovered the issue - it's a typo in App.js 我克隆了您的App.js并发现了问题-这是App.js的错字

{this.props.childen} -> {this.props.children} {this.props.childen} -> {this.props.children}

It works now. 现在可以使用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM