Giter Site home page Giter Site logo

task-react-routes-hiking-trips's Introduction

Instructions

Routes

  1. Install react-router-dom to your react app.
npm install react-router-dom
  1. In index.js import BrowserRouter from react-router-dom and wrap App with BrowserRouter.

  2. Import Route and Routes from react-router-dom.

  3. In App.js Wrap each component with Route and add its path.

  4. Wrap all your routes in Routes.

Navbar Links

  1. In Nav.js import NavLink from react-router-dom.

  2. Replace <a> tags with <NavLink> tags from react router dom and replace href with to so that Home shows you the Home.js component and Trips takes you to TripsList component.

  3. Add a style that if the page is active the link becomes underlined.

Trip Details

  1. In TripItem.js import <Link> again and wrap your whole div with it so it takes you to tripDetail component.
  2. in app.js details route /details, add a route param called tripId.
  3. Back to TripItem.js change the link to the tripDetail page to include the tripId.
  4. In TripDetail.js import useParams from react-router-dom.
  5. Extract the tripId coming from the url and store it in a variable called tripId.
  6. Find the correct trip from the trips data file.
  7. Import Navigate from react-router-dom and if the trip isn't found redirect the user to the home page.
  8. Switch from using ids to using slugs.

Challenge

  1. You have 3 buttons: easy, moderate and hard. when a button is clicked, filter the trips according to difficulty by changing the url, for example http://www.localhost:8000/trips?difficulty=easy Hint: useSearchParams

task-react-routes-hiking-trips's People

Contributors

yanalshmilan avatar ibraheemshaban avatar omsi96 avatar zainabbaq 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.