From 02accf86f38d76b4f2e8e02f99ec71f6954b4823 Mon Sep 17 00:00:00 2001 From: Jan Jaworski Date: Tue, 27 Sep 2022 11:40:31 +0200 Subject: [PATCH] fix: type of useTheme --- example/src/RootNavigator.tsx | 2 +- src/core/theming.tsx | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/example/src/RootNavigator.tsx b/example/src/RootNavigator.tsx index d3fb1cec8b..40dee37471 100644 --- a/example/src/RootNavigator.tsx +++ b/example/src/RootNavigator.tsx @@ -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(); diff --git a/src/core/theming.tsx b/src/core/theming.tsx index 59a491bc4a..d0c7da46b7 100644 --- a/src/core/theming.tsx +++ b/src/core/theming.tsx @@ -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, @@ -9,9 +9,16 @@ import { export const DefaultTheme = MD3LightTheme; -export const { ThemeProvider, withTheme, useTheme } = createTheming( - DefaultTheme as ReactNativePaper.Theme -); +const { + ThemeProvider, + withTheme, + useTheme: useThemeProviderTheme, +} = createTheming(DefaultTheme); + +const useTheme = (overrides?: Parameters[0]) => + useThemeProviderTheme(overrides); + +export { ThemeProvider, withTheme, useTheme }; export const defaultThemesByVersion = { 2: {