Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ritwickdey/my-react-router

Minimal version of React Router | Just for learning purpose
https://github.com/ritwickdey/my-react-router

learning-purpose react-router react-router-dom

Last synced: 3 days ago
JSON representation

Minimal version of React Router | Just for learning purpose

Awesome Lists containing this project

README

        

#### About

This is not `react-router-dom` (aka `react-router`) tutorial. It's a minimal version of `react-router-dom`.

If you're interested to know how `react-router-dom` is implemented, this repo will help you to understand how it actually works.

#### Syntax

```jsx
//Define Routes
import { BrowserRouter, Route, Redirect } from './lib/my-react-router';





;
```

```jsx
//Inside Component. `Link` and `props.history`
import { Link } from './lib/my-react-router';

function Home(props) {
return (


props.history.push('/login')}>
Login Page via click

Login page vai link

);
}
```

#### Code

[src/lib/my-react-route.js](src/lib/my-react-router.js) _(less than 100 lines)_


> Note: This sample project does not handle all edge cases and of course it's not as comprehensive as `react-router-dom`. I always wonder how react-router actually works, that is why I was trying out how I can implement it. That's all about the repo.


`:wq!`