reactjs - react-router.min.js:1 Uncaught TypeError: Cannot read property 'location' of undefined -


    <!-- included script -->    <script src="https://unpkg.com/react@15/dist/react.min.js"></script>   <script src="https://unpkg.com/react-dom@15/dist/react-dom.min.js"></script>   <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>   <script src="https://unpkg.com/react-router/umd/react-router.min.js"></script>            	<div id="root"></div>  	      <script type="text/babel">	  		  		var router = reactrouter.router;          var route = reactrouter.route;          var indexroute = reactrouter.indexroute;          var link = reactrouter.link;          var browserhistory = reactrouter.browserhistory;            class page extends react.component {                          render() {                  return (                       <div>                           <link to='/about'>india </link>                       </div>                  );              }          }            class extends react.component {                          render() {                  return (                          <div>                              router                          </div>                  );              }          }            class nomatch extends react.component {                          render() {                  return (                          <div>                             no page found                          </div>                  );              }          }            reactdom.render(              <router>                  <route path="/" component={page}>                      <route path="about" component={about}/>                      <route path="*" component={nomatch}/>                  </route>              </router>,              document.getelementbyid('root')          );        </script>     

it give me 'location' of undefined error. have tried slimier answers in other posts still not working me.

can 1 me solve issue?

thanks in advance.

react-router-dom

use react-router-dom ( dom bindings react router)

install

<script src="https://unpkg.com/react-router-dom/umd/react-router-dom.min.js"></script> 

use

just use reactrouterdom instead of reactrouter:

var router = reactrouterdom.browserrouter; var route = reactrouterdom.route; var link = reactrouterdom.link; 

you can find library on window.reactrouterdom.

github/react-router-dom

basic example

<router>   <div>     <route exact path="/" component={home}/>     <route path="/news" component={newsfeed}/>   </div> </router> 

https://reacttraining.com/react-router/web/api/route


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -