Typeerror:cannot Read property ' url ' of undefined

Source: Internet
Author: User

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 correcting

As 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}/>
Summary

In 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.