React-Router npm 包在控制台中给我警告? (不推荐使用 PropTypes)

React-Router npm package giving me warning in console? (PropTypes deprecated)

我目前正在使用 create-react-app 创建一个非常基本的 React 应用程序,这是代码:

index.js

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

import createBrowserHistory from 'history/createBrowserHistory';

import App from './App/AppComponent';

const browserHistory = createBrowserHistory();

ReactDOM.render(
    <Router path="/" history={browserHistory}>
        <div>
            <Route path="/" component={App} />
        </div>
    </Router>, document.getElementById('root')
);

AppComponent.js

import React, { Component } from 'react';

class App extends Component {
    render() {
        return (
            <div>This is the App component</div>
        );
    }
}

export default App;

当我 运行 这个应用程序时,我在控制台中收到以下警告:

bundle.js:11888 Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.

当我删除 react-router 相关的东西时,我似乎没有收到控制台警告所以我猜它来自那个包......但我以前在另一个小应用程序中使用过它并且没有没有错误,所以我有点困惑。

我在这里错过了什么?

这是 React 最近(2 天前)在 React v15.5. The change was that PropTypes are no longer included in React itself and instead are there own package (prop-types). This means that any library that is using React.PropTypes, which are most of them, are now showing this warning. An issue has already been filed with React Router 中做出的更改,并且还提交了一些拉取请求。我想这将在接下来的 24-48 小时内得到解决。所以现在,请忽略它。您的代码实际上没有任何问题。