Skip to content

Instantly share code, notes, and snippets.

@karol-majewski
Created June 10, 2021 00:57
Show Gist options
  • Save karol-majewski/7098f0ba47a790811c10b27e091bd82d to your computer and use it in GitHub Desktop.
Save karol-majewski/7098f0ba47a790811c10b27e091bd82d to your computer and use it in GitHub Desktop.
import React from 'react';
type DeferTypeInference<T> = [T][T extends any ? 0 : never];
interface Props<T extends string> {
themeMap: Record<T, any>
defaultTheme?: DeferTypeInference<T>;
}
class ThemeSwitcherProvider<T extends string> extends React.Component<Props<T>> { }
const themes = {
light: 'public/light.css',
dark: 'public/dark.css',
};
<ThemeSwitcherProvider defaultTheme="dark" themeMap={themes} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment