Babban matsalar da ke da alaฦa da shigar da React Router tare da npm shine cewa yana iya zama da wahala a tantance wane nau'in React Router ya dace da nau'in React ษin da kuke amfani da shi. Kamar yadda React da React na'ura mai ba da hanya tsakanin hanyoyin sadarwa ke ci gaba da sauri, sigogin dole ne su dace domin na'ura mai ba da hanya tsakanin hanyoyin sadarwa ya yi aiki da kyau. Bugu da ฦari, idan kuna da tsohuwar sigar React da aka shigar, ฦila ba ta dace da sabbin nau'ikan React Router ba. Saboda haka, yana da mahimmanci a duba dacewa kafin yunฦurin shigar da sabon sigar React Router.
To install React Router with npm, run the following command in your terminal: npm install react-router-dom
1. npm shigar: Wannan umarnin zai shigar da kunshin daga rajista na npm.
2. react-router-dom: Wannan shine sunan kunshin da za a shigar, wanda shine React Router DOM.
npm mai sarrafa kunshin
NPM (Node Package Manager) shine mai sarrafa fakitin JavaScript wanda ke ba masu haษakawa damar shigarwa, rabawa, da sarrafa fakitin lambobi don React Router. Shine mashahurin mai sarrafa fakitin JavaScript kuma yana ba da dama ga dubban ษakunan karatu waษanda za a iya amfani da su a aikace-aikacen React Router. NPM yana taimaka wa masu haษakawa da sauri gano da shigar da fakiti, da kuma sabunta su cikin sauฦi lokacin da ake buฦata. Hakanan yana ba masu haษaka damar ci gaba da bin diddigin abubuwan dogaro da su kuma tabbatar da cewa sun saba da sabbin nau'ikan. Bugu da ฦari, NPM yana sauฦaฦe raba lamba tsakanin ayyuka da haษin gwiwa tare da sauran masu haษakawa akan aikin.
React na'ura mai ba da hanya tsakanin hanyoyin sadarwa shigarwa tsari
Tsarin shigarwa don React Router yana da sauฦin kai tsaye.
1. Sanya kunshin react-router-dom daga npm:
'npm shigar react-router-dom'
2. Shigo bangaren BrowserRouter daga fakitin react-router-dom cikin app na React:
'shigo da {BrowserRouter} daga 'react-router-dom''
3. Kunna tushen tushen ku tare da bangaren BrowserRouter:
`
4. ฦara hanyoyi zuwa aikace-aikacenku ta amfani da abubuwan Route da Switch:
โโ