{"id":94,"date":"2024-08-16T02:19:55","date_gmt":"2024-08-16T02:19:55","guid":{"rendered":"https:\/\/www.yehger.com\/?p=94"},"modified":"2024-08-19T06:53:21","modified_gmt":"2024-08-19T06:53:21","slug":"how-to-get-get-current-route-in-react-router","status":"publish","type":"post","link":"https:\/\/www.yehger.com\/index.php\/2024\/08\/16\/how-to-get-get-current-route-in-react-router\/","title":{"rendered":"How to get get current route in React Router"},"content":{"rendered":"<h2>Using useLocation<\/h2>\n<pre><code class=\"language-jsx\">import * as React from &#039;react&#039;;\nimport { useLocation } from &#039;react-router-dom&#039;;\n\nfunction App() {\n  let location = useLocation();\n\n  React.useEffect(() =&gt; {\n    console.log(location)\n  }, [location]);\n\n  return (\n    \/\/ ...\n  );\n}<\/code><\/pre>\n<h2>Reference<\/h2>\n<p><a href=\"https:\/\/reactrouter.com\/en\/main\/hooks\/use-location\">https:\/\/reactrouter.com\/en\/main\/hooks\/use-location<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using useLocation import * as React from &#039;react&#039;; import { useLocation } from &#039;react-router-dom&#039;; function App() { let location =&#8230; <a class=\"read-more\" href=\"https:\/\/www.yehger.com\/index.php\/2024\/08\/16\/how-to-get-get-current-route-in-react-router\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-94","post","type-post","status-publish","format-standard","hentry","category-react-study"],"_links":{"self":[{"href":"https:\/\/www.yehger.com\/index.php\/wp-json\/wp\/v2\/posts\/94","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yehger.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yehger.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yehger.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yehger.com\/index.php\/wp-json\/wp\/v2\/comments?post=94"}],"version-history":[{"count":1,"href":"https:\/\/www.yehger.com\/index.php\/wp-json\/wp\/v2\/posts\/94\/revisions"}],"predecessor-version":[{"id":95,"href":"https:\/\/www.yehger.com\/index.php\/wp-json\/wp\/v2\/posts\/94\/revisions\/95"}],"wp:attachment":[{"href":"https:\/\/www.yehger.com\/index.php\/wp-json\/wp\/v2\/media?parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yehger.com\/index.php\/wp-json\/wp\/v2\/categories?post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yehger.com\/index.php\/wp-json\/wp\/v2\/tags?post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}