![]() ![]() In the src directory, add 2 new files: HomePage.js and AboutPage.js. Install the latest version of react-router-dom: At the time of writing, the most recent version of react-router-dom is 6.2.1. The library will be available globally on window.ReactRouter. Create a new project: The name is totally up to you. Var Route = require('react-router').RouteĪ build is also available on npmcdn. Not using an ES6 transpiler var Router = require('react-router').Router Then, create a component that exists of a basic Navbar with two items and basic pages: import React from 'react' Npm install react-router-dom or yarn add react-router-dom. ![]() ![]() Using either the script-loader with an import statement or just putting the tags in the base html file itself. It doesn't matter how I import the files. This getting started assumes you are working with create-react-app, or something equivalent using Babel and all the goodies out there.Īlso check out the great documentation right here. Whenever I change pages with react-router, through the Link component, these javascript files seem to stop working after the first page change. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |