React Font Awesome dole ne a sani ga kowane mai haษaka gaba-gaba ฦwararren React. Wannan fakitin yana ba ku gumaka masu sikeli waษanda za a iya keษance su - girman, launi, faษuwar inuwa, da sauransu tare da ikon CSS. Duk waษannan gumaka masu ban sha'awa an haษa su a cikin abin ban mamaki mai sauฦin amfani da React don app ษin ku.
Matsalar Hannu
Sau da yawa, haษa dakunan karatu na gumaka cikin aikace-aikacen React na iya haifar da batutuwan aiki da rikitattun saiti saboda haษa dukkan gumaka, ba tare da la'akari da amfani ba. Anan shine React Font Awesome yana haskakawa. Yana ba mu damar shigo da gumakan da ake buฦata kawai a cikin aikinmu, yana sa aikace-aikacen mu ya yi aiki.
Magani tare da React Font Awesome
Da farko, shigar da Font Awesome da fakitin da suka dace a cikin Ayyukan React ษinku ta amfani da umarni mai zuwa:
npm i --save @fortawesome/fontawesome-svg-core npm i --save @fortawesome/free-solid-svg-icons npm i --save @fortawesome/react-fontawesome
Yanzu kuna shirye don amfani da gumaka tare da waษannan layin lambar:
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faCoffee } from '@fortawesome/free-solid-svg-icons' const element = <FontAwesomeIcon icon={faCoffee} />
Lambar tana shigo da bangaren FontAwesomeIcon da gunkin kofi kuma yana amfani da su a bangaren React.
Bayanin mataki-mataki
Bari mu bincika yadda wannan ke aiki. Layin farko yana shigo da bangaren FontAwesomeIcon daga ษakin karatu na amsa-fontawesome. "FontAwesomeIcon" wani bangare ne kawai wanda Font Awesome ke bayarwa don amfani a cikin abubuwan da aka gyara na React. Layi na gaba yana shigo da gunki guda ษaya (
- kafi
) daga fakitin-m-svg-gumakan kyauta. A ฦarshe, kuna amfani da gumakan da aka shigo da su azaman abin dogaro ga bangaren FontAwesomeIcon.
ฦari Game da Dakunan karatu na FontAwesome
Kunshin @fortawesome/fontawesome-svg-core shine ainihin Font Awesome. Ya ฦunshi salo da ayyukan tsarin SVG kuma yakamata a haษa su sau ษaya a kowane aiki.
The @fortawesome/free-solid-svg-gumakan kunshin ya ฦunshi duk waษannan gumaka masu ฦarfi kyauta waษanda galibi za ku yi amfani da su a cikin rukunin yanar gizonku/app. Hakanan ana samun sauran ษakunan karatu kamar na yau da kullun da samfuran iri.
The @fortawesome/react-fontawesome kunshin babban ษakin karatu ne don kawo FontAwesome cikin React ba tare da matsala ba.
React Font Awesome ya tabbatar da zama ingantaccen bayani don aiwatar da gumaka a cikin aikace-aikacen React yayin kiyaye aikace-aikacen ingantaccen kuma madaidaiciya.