📜  上下文挂钩 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:40.398000             🧑  作者: Mango

代码示例1
const themes = {
  light: {
    foreground: "#000000",
    background: "#eeeeee"
  },
  dark: {
    foreground: "#ffffff",
    background: "#222222"
  }
};

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

function App() {
  return (
    
      
    
  );
}

function Toolbar(props) {
  return (
    
); } function ThemedButton() { const theme = useContext(ThemeContext); return ( ); }