I have a very basic react app I'm creating using create-react-app currently, and this is the code:
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;
And I get the following warning in the console when I run this app:
bundle.js:11888 Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.
When I remove the react-router related stuff, I don't seem to get the console warning so my guess is it's coming from that package... but I've used it in another small app previously and didn't have the error so I'm a bit confused.
What am I missing here?
Thus, we found that a lot of the packages were deprecated and needed to be replaced ASAP. One of the biggest surprises for us was the deprecation of react-router-redux .
The answer is no. React Router – like the name implies – helps you route to/navigate to and render your new component in the index. html file. So as a single page application, when you navigate to a new component using React Router, the index.
In order to solve the 'Switch' is not exported from 'react-router-dom' error in ReactJs, we need to update the syntax of the routes defined. From version 6 onwards, the react-router-dom has replaced “Switch” with “Routes”.
This is a recent change (2 days ago) that React made in 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 specifically and a few pull requests have also been submitted. I imagine this will be fixed within the next 24-48 hours. So for now, just ignore it. There's nothing actually wrong with your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With