How to Access URL Parameters in ReactJS
Channel: Christian Hur
Date: 2021-04-28

⭕ Overview
In this tutorial, I'm excited to demonstrate how to access URL parameters in a React application, a crucial skill for creating dynamic web pages that respond to user input and navigation changes.

We'll focus on a common scenario where a user might click an "Edit" button on a website, and you need to retrieve a unique identifier (ID) from the URL to fetch and display the correct data. I'll walk you through setting up a React component to handle URL parameters using React Router, explaining how to capture these parameters and use them to perform operations like fetching data from a server or filtering a list.

By implementing this functionality, your React applications will become more interactive and user-friendly, providing a smooth experience as users navigate through different parts of your application and interact with individual elements.

This session is designed to enhance your React development skills by adding practical knowledge that can be applied in various web development projects.

If you find this video helpful, please give it a thumbs up, share it with your friends, and subscribe to my channel for more tutorials and insights into programming. Your support helps me create more content to assist you in your learning journey. Thank you for watching!

React Router version 6 introduces several powerful new features which include a few breaking changes from version 5. Below are two changes that you will need to adhere to if you're running version 6.

(1) The Switch component has been replaced with a new Routes component. You'll need to convert all your Switch elements to Routes.

(2) A new element property replaces the render property/function. Thus passing URL parameters to class components can still be done using a Wrapper function component. Function components retrieve URL parameters in the usual way using Hooks.

Examples on how to retrieve URL parameters in either stateless or stateful components using React Router 6 can be found on my GitHub Repo below.

https://github.com/ChristianHur/152-001-Front-End-Dev-With-React/tree/main/react-router-example

⭕ Chapters
  0:00 - Introduction
 1:50 - Routes
 2:40 - Access URL params in a stateless (function) component
 6:28 - Access URL params in a stateful (class) component

⭕ About me
I am a Web instructor and author for Linkedin Learning (formerly Lynda.com), Packt, E-C Council, Udemy, and MC Press.

⭕ Visit my site: https://christianhur.com
⭕ My complete online training courses:
      ☑️ REST APIs & AJAX Operations Using Node, Express, and jQuery:  https://www.udemy.com/course/rest-apis-ajax-operations-using-node-express-and-jquery/?referralCode=A762AE70D9FD6A931F9B
      ☑️ Build Clean and Secure PHP Web Apps From Scratch:  https://www.udemy.com/course/build-clean-and-secure-php-web-apps-from-scratch/?referralCode=C200BB52F0C7153B93CC
      ☑️ Angular 9 New Features: https://www.packtpub.com/web-development/angular-9-new-features-video
      ☑️ Full-Stack Web Development with Flask: https://www.packtpub.com/web-development/full-stack-web-development-flask-video
      ☑️ Full-Stack Web Development with Django & Angular 8: https://www.packtpub.com/web-development/full-stack-web-development-with-django-and-angular-8-video
      ☑️ Angular 7 New Features:  https://www.packtpub.com/web-development/angular-7-new-features-video
      ☑️ The DOM in JavaScript, jQuery, AngularJS, and React : https://www.linkedin.com/learning/the-dom-in-javascript-jquery-angularjs-and-react
      ☑️ Building JSF Web Applications with Java EE 7:  https://www.linkedin.com/learning/building-jsf-web-applications-with-java-ee-7
      ☑️ Troubleshooting Vue.js:  https://www.packtpub.com/application-development/troubleshooting-vuejs-video

⭕ Check out my book:
Developing Business Applications for the Web: With HTML, CSS, JSP, PHP, ASP.NET, and JavaScript is available on Amazon and MC Press. 
      ☑️ Link:  https://www.mc-store.com/collections/christian-hur/products/developing-business-applications-for-the-web-with-html-css-jsp-php-asp-net-and-javascript