Context API — avoid prop drilling by passing data through component tree.
1const ThemeContext = createContext("light");23function App() {4 return (5 <ThemeContext.Provider value="dark">6 <ChildComponent />7 </ThemeContext.Provider>8 );9}1011function ChildComponent() {12 const theme = useContext(ThemeContext);13 return <Text style={{ color: theme === "dark" ? "white" : "black" }}>Text</Text>;14}
Performance tips:
useMemo for value objects