Scribe
Scribe

Gostou? Torne o Scribe ainda melhor deixando uma avaliação

Obter Extensão do Chrome

Navegar

  • Vídeos Populares
  • Vídeos Recentes
  • Todos os Canais

Ferramentas Gratuitas

  • Baixador de Legendas de Vídeo
  • Gerador de Marcadores de Tempo de Vídeo
  • Resumidor de Vídeos
  • Contador de Palavras de Vídeo
  • Analisador de Títulos de Vídeo
  • Busca de Transcrições de Vídeo
  • Análises de Vídeo
  • Criador de Capítulos de Vídeo
  • Gerador de Quiz de Vídeo
  • Chat com Vídeo

Produto

  • Preços
  • Blog
  • Obter Extensão do Chrome

Developers

  • Transcript API
  • API Documentation

Legal

  • Termos
  • Privacidade
  • Suporte
  • Mapa do Site

Direitos Autorais © 2026. Feito com ♥ por Scribe

— Se isso tornou sua vida mais fácil (ou pelo menos um pouco menos caótica), deixe-nos uma avaliação! Prometemos que vai alegrar nosso dia. 😊

Related Videos

React Router Tutorial - 12 - Search Params

Video thumbnail
73.09k802 Palavras4m readGrade 18
Compartilhar
Channel
Codevolution
in the previous two videos we learned about dynamic routes and url params which represent part of the url that is dynamic we also learned how to extract the dynamic param within a component using the use param hook what you should know is that url params is not the only way to add parameters to a route we can also add an optional query string for example at the end of the current url question mark filter is equal to active these parameters are called search params in react router for our understanding let's implement a simple scenario in
the users page let's add two buttons one that says active users and one that says reset filter by default the page renders the text showing all users on click of active users we're going to add a search param called filter and set it to active in the component we will display text showing active users if you click on reset we remove the filter search param and revert the text now changing the text is pretty simple and your app might have more complex requirements i just want to ensure you understand the concept of search params and
how to put it to use is up to you let's begin for step one in the user's component let's add two buttons active users and the second button is reset filter for step two on click of these buttons we need to add or remove the search param to deal with search params react router provides a hook called use search params import imported at the top this hook behaves similar to the use state hook in react instead of storing state in memory though it is stored in the url within the component invoke the hook use search
patterns the hook returns two values of which the first one is an object which we are going to call as search patterns the second value returned is a function to set the search patterns so let's call this set search patterns as you can see it is very similar to use state now using said search params function we can add or remove the parameter first on click of active users button on click we're going to have an arrow function where we call set search params and we pass in an object with one property called filter this
value is active next on click of reset filter button we call set search params again but this time with an empty object let's save the file and test if this works so we are here at localhost 3000 slash users i click on active users and you can see we have question mark filter is equal to active click on reset filter and the search param is removed now what we need to do is check if filter search param is set to active and display the appropriate text so for step 3 within the component we make a
check on the filter parameter const show active users and this is going to be a boolean value to get hold of the filter parameter we use the get function on search params so search params dot get what is the pattern name it is filter we then compare the value with the string active so show active users is true if we click on active users button and false if we click on reset filter button let's use it to render the jsx curly braces show active users if it is true return an h2 tag that says showing
active users and if it is false return an h2 tag that says showing all users and for now take a look at the browser you can see the text showing all users click on active users we see the search param in the url and the text is now showing active users we said filter showing all users once again our code with search params is working as expected now using search patterns is pretty common when you have to apply filters in a listing page for example on a website like amazon or any ecommerce site you'll have
a list of parameters on the left hand side selecting a filter will update the url with a search param this lets you share the link with others or even bookmark the link hopefully you now have an idea of how to implement such scenarios import the use search params hook and invoke it you get access to the set search params function to set the value and search params object to get any value present in the url alright then thank you all for watching make sure to subscribe to the channel and i'll see you in the next
video you
Vídeos relacionados
React Router Tutorial - 13 - Relative Links
2:45
React Router Tutorial - 13 - Relative Links
Codevolution
41,964 views
useParams Hooks in React Router in Hindi in 2020 #57
16:56
useParams Hooks in React Router in Hindi i...
Thapa Technical
137,123 views
React Router Tutorial - 15 - Authentication and Protected Routes
19:46
React Router Tutorial - 15 - Authenticatio...
Codevolution
149,657 views
React Router Tutorial - 10 - Dynamic Routes
9:26
React Router Tutorial - 10 - Dynamic Routes
Codevolution
97,791 views
React router crash course
1:04:35
React router crash course
Chai aur Code
322,042 views
Using multiple Params in React Routing #reactjs
17:13
Using multiple Params in React Routing #re...
Studytonight with Abhishek
7,138 views
React Router V6 Tutorial - Routes, Redirecting, UseNavigate, UseParams...
20:42
React Router V6 Tutorial - Routes, Redirec...
PedroTech
279,164 views
Learn React Router v6 In 45 Minutes
46:20
Learn React Router v6 In 45 Minutes
Web Dev Simplified
570,216 views
React Router Tutorial - 14 - Lazy Loading
6:45
React Router Tutorial - 14 - Lazy Loading
Codevolution
124,275 views
How I Write Clean Code in React
16:36
How I Write Clean Code in React
Cosden Solutions
32,478 views
Learn React Router v6 – Full Course
1:43:23
Learn React Router v6 – Full Course
freeCodeCamp.org
61,130 views
React Router v6 tutorial in Hindi #7 use SearchParams and  setSearchParmas
7:57
React Router v6 tutorial in Hindi #7 use S...
Code Step By Step
40,291 views
STOP using useState, instead put state in URL (in React & Next.js)
21:41
STOP using useState, instead put state in ...
ByteGrad
224,331 views
React Router v6 tutorial in Hindi #4 dynamic Routing with params
9:44
React Router v6 tutorial in Hindi #4 dynam...
Code Step By Step
69,896 views
React Router in Depth #6 - Loaders
12:07
React Router in Depth #6 - Loaders
Net Ninja
60,512 views
React Router (How-to) 2024
13:07
React Router (How-to) 2024
Code Commerce
16,127 views
React useEffect() hook introduction 🌟
19:52
React useEffect() hook introduction 🌟
Bro Code
32,043 views
React Protected Routes | Role-Based Authorization | React Router v6
30:43
React Protected Routes | Role-Based Author...
Dave Gray
392,408 views
React Router 6 – Tutorial for Beginners
1:17:25
React Router 6 – Tutorial for Beginners
freeCodeCamp.org
159,689 views