Introduction
The use of react-router feel or there is a certain "curve", first of all to be familiar with ES6 and do not say, for JSX extended grammar and React-router about the route of the expression of a little sloppy can not. When the error appears title, I searched the network, unexpectedly did not find several places to refer to. There is one of the following:
https://teamtreehouse.com/community/typeerror-cannot-read-property-url-of-undefined
The situation with me here is not the same, later on the stackoverflow.com directly search, also did not find. Not inspired by the former, or finally dug out the problem, rejoicing, or decided to record it down.
Error description
Import React, {Component} from ' React '; import {Link, Route,} from ' React-router-dom '; const home= () = (<DIV&G T;
This example is to test the React-router client nesting routines by the relevant conclusions. The code above defines the component category, where the problem occurs at the near end of the component's reference. The following syntax error message appears when you run NPM start through the Webstorm built-in console:
Error correctingAs mentioned earlier, the problem is referenced by the category component at the near end, and the correct expression should be:
<Route exact={true} path="/" component={Home}/> <Route path="/category" component={Category}/> <Route path="/products" component={Products}/>
SummaryIn the React-router world, everything is a component, and may be affected by the expression of semantic-ui for react in the previous period, so that the above superficial error is made. Among them, in react-router <Route> components nesting How many layers is not matter, as long as there is need, and almost informal position. React-router Beginners can learn a little bit.
Typeerror:cannot Read property ' url ' of undefined