An warware: amsa samun hanyar yanzu

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.

Shafi posts:

Leave a Comment