Warning: Failed prop type: Invalid prop 'component' supplied to 'Route' - react-router-dom
Change this <Route component={<NotFound />} />
to this: <Route component={NotFound} />
This is pretty standard behavior for libraries like this. They want to render the component like this: <component />
rather than like this: {component}
.
Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function`
When using a lazy loaded component, you would need to supply it to the Route component like
// imports here
...
const Decks = React.lazy(() => import('./pages/Decks'));
...
class App extends Component {
...
render() {
return (
<ConnectedRouter history={history}>
<div>
<MenuAppBar />
<div style={{paddingTop: '4rem'}}>
<Suspense fallback={<LazyLoading />}>
<Switch>
<Route exact path="/" component={Home} />
<Route path="/decks" render={(props) => <Decks {...props} />} />
...
</Switch>
</Suspense>
</div>
<Footer />
</div>
</ConnectedRouter>
);
}
...
}
Probably its an incorrect PropType check in react-router and may have been fixed in the latest versions to make it compatible with react v16.6
Warning: Failed prop type: Invalid prop `component` supplied to `Route`. & Warning: [react-router] Location "/" did not match any routes
Checkout if the filenames and import statements have the correct spelling.
pages.js should be Pages.js
Indexpage.js should be IndexPage.js
Or change it in the import statements.. its case-sensitive.
The docs says you have to wrap your Routes with a main Router /
<Router history={browserHistory}>
<Route path="/" component={App}>
<Route path="about" component={About}/>
<Route path="users" component={Users}>
<Route path="/user/:userId" component={User}/>
</Route>
<Route path="*" component={NoMatch}/>
</Route>
</Router>
// this is the main App component
const App = ({children}) => (
<div id="main-layout">{children}</div>
)
Failed prop type while doing prop validation in React.js
React.ReactNode
is undefined
in javascript. If you're using typescript it would be a type, but even that only exists at compile time and cannot be used for propTypes.
Instead, the way to do the children prop type is:
import PropTypes from 'prop-types';
// ...
CurrencyContextProvider.propTypes = {
children: PropTypes.node
}
Related Topics
No Overload Matches This Call. Type 'String' Is Not Assignable to Type 'Signals'
How to Get Checkbox Variables Using Ajax
Show 2 Items Per Row[React Native]
How to Count Duplicate Value in an Array in JavaScript
Cors - Response to Preflight Request Doesn't Pass Access Control Check
Google Charts - Labels Are Not Showing
How to Use Lodash to Remove Keys from a Json Object
Get Substring Between Two Characters Using JavaScript
Javascript Function (Input Date Bigger Than Today Date)
How to Format a Number to 2 Decimal Places, But Only If There Are Already Decimals
How to Store Multiple Items in Local Storage
Disable F5 and Browser Refresh Using JavaScript
How to Set the Multi Sliders in One Page