QuizzesRoute Params and Search Params as State — Concept Check
intermediate
react

Route Params and Search Params as State — Concept Check

Questions on Route Params and Search Params as State. Path params identify a resource, search params describe a view. Treating search params as your filter state makes every view shareable and refresh-proof for free.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on Route Params and Search Params as State — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A React app uses search params to manage filter state. After setting a filter, the user presses the back button. What should happen?

    • AA new filter state is applied
    • BThe previous filter state is restored
    • CThe filter state remains unchanged
    • DThe app crashes due to missing state
  2. 2.In a React app, a developer uses useParams to extract a path parameter as an integer ID. What must they ensure?

    • AThe ID is parsed and checked for validity
    • BThe ID is always a positive integer
    • CThe ID is converted to a string
    • DThe ID is stored in local state
  3. 3.A developer wants to make a tab selection in a React app shareable via URL. Where should this state be stored?

    • AIn the component's local state
    • BIn a session storage
    • CIn the URL as a search param
    • DIn a global state management system
  4. 4.What happens if a required path parameter is missing in a React app using React Router?

    • AThe component renders without data
    • BThe component defaults to a fallback view
    • CThe component displays an error
    • DThe component crashes
  5. 5.A user refreshes a page with search params in the URL. What is the expected behavior?

    • AThe page loses its state
    • BThe page shows default state
    • CThe page displays a 404 error
    • DThe page retains its state
  6. 6.A developer uses useSearchParams to manage pagination. What should they do when a filter changes?

    • AReset the page number
    • BKeep the current page number
    • CSet a default filter
    • DRemove all search params
  7. 7.Which of the following should never be included in a URL?

    • ASort order
    • BFilter state
    • CPage number
    • DUser tokens