Isonjululwe: phendula fumana indlela yangoku

Ingxaki engundoqo ngokufumana indlela yangoku kukuba inokucotha.

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

igama

uselocation() hook

I-uselocation () ihuku isetyenziselwa ukumisela ukuba ilungu kufuneka linikezelwe kwingcambu okanye hayi. Ukuba icandelo akufuneki linikezelwe kwingcambu, linokusebenzisa le hook ukumisela apho kufuneka inikezelwe endaweni yoko.

Uzifumana njani iindlela

Kukho iindlela ezimbalwa zokufumana iindlela kwi-React. Enye indlela kukusebenzisa i-react-router. Enye indlela kukusebenzisa i-react-router-dom.

Izithuba ezihambelanayo:

Shiya Comment