Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .idea/React-Router-Basic-Nav.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

240 changes: 240 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ Topics:

### Steps for implementing React Router

* You'll notice we've already installed react-router-dom for you.
* `import` your BrowserRouter as Router inside your `index.js` file.
* Wrap your `<App />` component that you're passing to `ReactDOM.render()` with your new `Router` component.
* open up your chrome `REACT DEV TOOLS` and notice your app is now all wrapped in `BrowserRouter`
* inside the `REACT DEV TOOLS` expand `<BrowserRouter>` and highlight `<Router>` and notice that here is a `"history"` object on props and a `"match"` object on its state. These two objects are how all of our Router is going to work.
X You'll notice we've already installed react-router-dom for you.
X `import` your BrowserRouter as Router inside your `index.js` file.
X Wrap your `<App />` component that you're passing to `ReactDOM.render()` with your new `Router` component.
X open up your chrome `REACT DEV TOOLS` and notice your app is now all wrapped in `BrowserRouter`
X inside the `REACT DEV TOOLS` expand `<BrowserRouter>` and highlight `<Router>` and notice that here is a `"history"` object on props and a `"match"` object on its state. These two objects are how all of our Router is going to work.

### Steps for "Declaring" your routes

* Inside of your `App.js` file `import { Route } from 'react-router-dom';`
* This is where we're going to declare and specify our router.
* Create 3 `<Route />` setting their `path` prop equal to `/`, `/about`, `/contact` with their respective components.
* Be sure to incluce the `exact` prop on the root component for `/` to make sure that it's rendering the exact component and not all the other components.
X Inside of your `App.js` file `import { Route } from 'react-router-dom';`
X This is where we're going to declare and specify our router.
X Create 3 `<Route />` setting their `path` prop equal to `/`, `/about`, `/contact` with their respective components.
X Be sure to include the `exact` prop on the root component for `/` to make sure that it's rendering the exact component and not all the other components.

### Steps for setting up your Navigation

* Inside of `Navigation.js` `import { Link } from 'react-router-dom'`.
* Declare the `to` as the href on `<Link>` and specify the correct routes for your app to navigate towards.
* Head over to your app and start navigating. You should be able to see your URLS changing their paths as you go. Each path should display the proper component.
X Inside of `Navigation.js` `import { Link } from 'react-router-dom'`.
X Declare the `to` as the href on `<Link>` and specify the correct routes for your app to navigate towards.
X Head over to your app and start navigating. You should be able to see your URLS changing their paths as you go. Each path should display the proper component.

### Resources

Expand Down
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,17 @@
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
14 changes: 10 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import React from 'react';
import './App.css';
import { Home, About, Contact, Navigation } from './components';
import {Home, About, Contact, Navigation} from './components';
import {Route} from 'react-router-dom';



const App = () => (
<div>
<Navigation />
</div>
<div>
<Navigation/>
<Route exact path="/" component={Home}/>
<Route path="/about" component={About}/>
<Route path="/contact" component={Contact}/>
</div>
);

export default App;
32 changes: 18 additions & 14 deletions src/components/Navigation.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import React from 'react';
import {Link} from 'react-router-dom';

const Navigation = () => {
return (
<div>
<div className="App">
<h1>React Router Mini</h1>
return (
<div>
<a href="">Home</a>
<div className="App">
<h1>React Router Mini</h1>
<div>
<Link to="/">Home</Link>
</div>
<div>
<Link to="/about">About</Link>
</div>
<div>
<Link to="/Contact">Contact</Link>
</div>
</div>
</div>
<div>
<a href="">About</a>
</div>
<div>
<a href="">Contact</a>
</div>
</div>
</div>
);
);
};

export default Navigation;



Loading