Git Product home page Git Product logo

windsuzu / react-router-demo Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 2.48 MB

A comprehensive demo showing the use of react-router-dom v6.

Home Page: https://windsuzu.github.io/react-router-demo

License: MIT License

HTML 7.01% JavaScript 89.80% CSS 3.19%
react-router-dom-v6 reactjs styled-components browser-router routes link nav-link useparams uselocation urlsearchparams navigate usenavigate

react-router-demo's Introduction

Contributors MIT License Author LinkedIn


Ux icons created by Flowicon - Flaticon

React Router Demo

A comprehensive demo showing the use of react-router-dom v6.
View Demo · Report Bug · Request Feature

Table of Contents

About

這個專案主要展示如何使用 react-router-dom@v6 讓一個 SPA (Single-Page Application) 專案能夠自由控制 url 與頁面轉換。內容包含:

  1. 建立 Routes 邏輯
  2. 建立 Link 或含有 active 風格的 NavLink
  3. 在 component 中建立 nested routes
  4. 利用 useParams 與 useLocation、URLSearchParams 存取 url 資訊
  5. 利用 navigate 與 useNavigate 來改變 url,做到 replace 或 push 頁面,甚至使用 url 取代 state 功能

❤️ 另外,下方的 [Difference between v5 and v6] 區塊也整理了 react-router-dom 的 v5 和 v6 差別。

Built With

  • HTML5, CSS3, Javascript ES6
  • React.js
  • styled-components
  • react-router-dom@v6

[DEMO] : https://windsuzu.github.io/react-router-demo


Examples

🪃 Setup Routes

⚔️ Nested Routes

🗡️ Using Links and NavLinks

🛡️ Extracting URL Params (useLocation, useParams)

🩸 Redirect, Navigation, Imperative Navigation

Preview


Difference between v5 and v6

❤️ Browser Router

❤️ Routes and Route Components

❤️ Display Subroute

❤️ NavLink Active Status

❤️ useParams

❤️ Redirect => Navigate

❤️ Route inside Components

🎆 Outlet (v6 only)

❤️ Imperative Navigation

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Reach out to the maintainer at one of the following places:

Acknowledgements

react-router-demo's People

Contributors

windsuzu avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.