Kuxazululiwe: sabela thola umzila wamanje

Inkinga enkulu ngokuthola umzila wamanje ukuthi ungahamba kancane.

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

Ihhuku le-uselocation() lisetshenziselwa ukunquma ukuthi ingxenye kufanele inikelwe yini empandeni noma cha. Uma ingxenye kungafanele inikezwe empandeni, ingasebenzisa le hook ukuze inqume ukuthi kufanele inikelwe kuphi esikhundleni salokho.

Ungayithola kanjani imizila

Kunezindlela ezimbalwa zokuthola imizila ku-React. Enye indlela ukusebenzisa i-react-router. Enye indlela ukusebenzisa i-react-router-dom.

Okuthunyelwe okuhlobene:

Shiya amazwana