Horje
Context hook Code Example
Context hook
const themes = {
  light: {
    foreground: "#000000",
    background: "#eeeeee"
  },
  dark: {
    foreground: "#ffffff",
    background: "#222222"
  }
};

const ThemeContext = React.createContext(themes.light);

function App() {
  return (
    <ThemeContext.Provider value={themes.dark}>
      <Toolbar />
    </ThemeContext.Provider>
  );
}

function Toolbar(props) {
  return (
    <div>
      <ThemedButton />
    </div>
  );
}

function ThemedButton() {
  const theme = useContext(ThemeContext);  return (    <button style={{ background: theme.background, color: theme.foreground }}>      I am styled by theme context!    </button>  );
}
Source: reactjs.org




Javascript

Related
display array javascript Code Example display array javascript Code Example
age from date Code Example age from date Code Example
encodeurl in javascript Code Example encodeurl in javascript Code Example
calculate age from date of birth js Code Example calculate age from date of birth js Code Example
is array php Code Example is array php Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6