We’ll use React-Router to organize the paths to our various React components.
From your NPM server install react-router.
npm install --save react-router-dom
Delete src/App.js - we aren’t referencing it any more.
Up to now everything has been generic as we get React set up. A number of my examples from here on will be code from my actual project.
Create a folder to hold our components.
In AngularJS I have a file: comic.module.js. It handles all of my angular component routing. Its code looks like this:
We need equivalent component routing in our React files.
Add routing to our new component.
In AngularJS our component has 3 parts: the component, the controller, and the html. React combines all of those onto the same ‘component’ page.
Create the skeleton of the component.
Inside our class, functions (for example ‘constructor’) will handle our logic. Inside ‘return’ in the ‘render’ we’ll put our HTML.