Babban matsala tare da amsa samun hanyar yanzu shine cewa yana iya zama a hankali.
There is no built-in way to get the current route in React. However, you can use the router's context to get the current location, which will give you the current pathname. const { location } = this.context.router; console.log(location.pathname); // /some/path
sunan
uselocation() ฦugiya
Ana amfani da ฦugiya mai amfani () don tantance ko ya kamata a sanya wani sashi a tushen ko a'a. Idan bai kamata a sanya sashin a tushen ba, zai iya amfani da wannan ฦugiya don tantance inda ya kamata a sanya shi maimakon.
Yadda ake samun hanyoyi
Akwai 'yan hanyoyi don samun hanyoyi a cikin React. Hanya ษaya ita ce amfani da react-router. Wata hanya ita ce ta amfani da react-router-dom.