Skip to content

Commit

Permalink
fix: type of useTheme
Browse files Browse the repository at this point in the history
  • Loading branch information
jaworek committed Sep 27, 2022
1 parent a3916db commit 02accf8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/src/RootNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
createStackNavigator,
} from '@react-navigation/stack';
import { getHeaderTitle } from '@react-navigation/elements';
import ExampleList, { examples } from './ExampleList';
import { Platform } from 'react-native';
import ExampleList, { examples } from './ExampleList';

const Stack = createStackNavigator();

Expand Down
15 changes: 11 additions & 4 deletions src/core/theming.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createTheming } from '@callstack/react-theme-provider';
import type { Theme } from 'src/types';
import type { Theme, MD2Theme, MD3Theme } from 'src/types';
import {
MD2DarkTheme,
MD2LightTheme,
Expand All @@ -9,9 +9,16 @@ import {

export const DefaultTheme = MD3LightTheme;

export const { ThemeProvider, withTheme, useTheme } = createTheming<Theme>(
DefaultTheme as ReactNativePaper.Theme
);
const {
ThemeProvider,
withTheme,
useTheme: useThemeProviderTheme,
} = createTheming<Theme>(DefaultTheme);

const useTheme = (overrides?: Parameters<typeof useThemeProviderTheme>[0]) =>
useThemeProviderTheme<MD2Theme | MD3Theme>(overrides);

export { ThemeProvider, withTheme, useTheme };

export const defaultThemesByVersion = {
2: {
Expand Down

0 comments on commit 02accf8

Please sign in to comment.