Casharka 2: Sida Loo Rakibo React.js Adoo Isticmaalaya create-react-app
Hordhac
React.js waa maktabad xoog leh oo loogu talagalay dhismaha interface-ka isticmaalaha ee webka. Waxaa loogu talagalay in ay sahlanaato iyo in ay korodho waxqabadka. Maqaalkan waxaan ku eegi doonaa sida loo rakibo React.js adoo isticmaalaya create-react-app
, oo ah aalad fudud oo ka caawisa bilowga mashruucaaga React.
Installation - Sida loo rakibo React.js adoo isticmaalaya create-react-app. |
1. Haddii Aad U Baahan Tahay
Ka hor inta aadan bilaabin, xaqiiji in kombuyuutarkaaga uu leeyahay Node.js iyo npm (Node Package Manager). Si aad u hubiso:
Node.js: Furo terminalkaaga (ama Command Prompt) oo geli:
bashnode -v
Haddii Node.js uu horey u rakibnaa, waxaad arki doontaa nooca. Haddii kale, waxaad ka soo dejisan kartaa Node.js oo raac tilmaamaha rakibida.
npm: Npm waa qayb ka mid ah Node.js. Si aad u hubiso, geli:
bashnpm -v
2. Rakibida create-react-app
create-react-app
waa qalab rasmi ah oo React ah oo ka dhigaya bilowga mashruuca mid sahlan. Si aad u rakibto, furo terminalkaaga oo geli:
bashnpx create-react-app magaca-mashruucaaga
Halkan, magaca-mashruucaaga
waa magaca aad u bixineyso mashruucaaga cusub. Tani waxay abuuri doontaa galka cusub oo ku jira dhammaan faylasha lagama maarmaanka u ah React.
3. Gali Galka Mashruuca
Marka rakibida la dhammeeyo, geli galka mashruucaaga:
bashcd magaca-mashruucaaga
4. Orod Mashruuca
Si aad u bilowdo server-ka horumarinta oo aad u aragto mashruucaaga browser-ka, geli:
bashnpm start
Tani waxay furi doontaa browser cusub oo muujinaya boggaaga React. Waxaad arki doontaa fariin ah "Edit src/App.js
and save to reload" oo muujinaysa in mashruucaaga si guul leh loo rakibay.
5. Fahamka Qaab-Dhismeedka
public/
: Qaybtan waxay ku leedahay faylasha aan isbeddel lahayn sidaindex.html
.src/
: Qaybtan waxaa ku jira faylasha React, sidaApp.js
iyoindex.js
.node_modules/
: Qaybtan waxay ku leedahay dhammaan maktabadaha aad ku rakibtay mashruucaaga.package.json
: Faylkan wuxuu ku xiran yahay dhammaan isbedelada iyo maktabadaha loo baahan yahay.
6. Xiritaanka
Marka aad dhamayso, waxaad xirtaa server-ka horumarinta adigoo isticmaalaya Ctrl+C
gudaha terminalkaaga.
Gunaanad
Waxaan ku baranay sida loo rakibo React.js adoo isticmaalaya create-react-app
. Hadda waxaad diyaar u tahay inaad bilowdo horumarinta interface-yadaaga isticmaalaha ee webka adoo isticmaalaya React. Qaybaha xiga waxaan ku baran doonaa sida loo dhiso qaybaha React iyo sida loo maareeyo xaaladaha.