I am new to React. I am using it by directly adding the react.js and react-dom.js files along with browser.min.js for javascript transformation in to my HTML page for practice. Now, I want to use react-router for which I have added ReactRouter.js script file from here. However, I am not able to find any examples to know how to use it. I have tried the following way and its not working:
<Router history={history}>
<Route path="/" component={MainComponent}>
//<Route path="topics/:id" compponent={Topic} />
</Route>
</Router>
ReactDOM.render(<Router />, document.getElementById('wrapper'));
Can you please help me how to use Router from ReactRouter.js (CDN way) with an example. Thank you.
let Router = window.ReactRouter;
let RouteHandler = Router.RouteHandler;
let Route = Router.Route;
let DefaultRoute = Router.DefaultRoute;
Add these codes to the top of yours to get the true reference.
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