React & React Native

useContext

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

useContext lexon një vlerë nga një Context — p.sh. përdoruesin e kyçur ose temën — pa pasur nevojë ta kalosh me props nëpër shumë nivele.

EnglishEN

useContext reads a value from a Context — e.g. the logged-in user or the theme — without passing it through props across many levels.

Si ta mendosh

Si tabela e njoftimeve e shkollës: kushdo e lexon pa pasur nevojë t'ia tregojë njëri-tjetrit.

Lexoje në anglisht

Like the school noticeboard: anyone can read it without it being passed person to person.

Shembull kodijavascript

const Tema = createContext("light");
function Butoni() {
  const tema = useContext(Tema);
  return <button className={tema}>OK</button>;
}

Terma të lidhur