DEV Community

Rahul Chandra
Rahul Chandra

Posted on

React Native : How to override types in react navigation theme and add more

Hi,
How we can add more theme color's other than that are specified types in types
There are different methods the method i followed is by adding a global.d.ts fil e in type folder in src and mentioning the colors needed types there and extending the theme class of react navigation

import '@react-navigation/native';
// Override the theme in react native navigation to accept our custom theme props.
declare module '@react-navigation/native' {
export type Theme = {
dark: boolean;
colors: {
primary: string;
background: string;
background2: string;
card: string;
btColor: string;
text: string;
text2: string;
border: string;
notification: string;
};
};
export function useTheme(): Theme;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)