Skip to content

Commit

Permalink
feat: add theme to ComponentFunctionProps (react-native-elements#3645)
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitBhalla authored Oct 1, 2022
1 parent 6654ca4 commit 4caef0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/themed/src/config/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export type { RecursivePartial };
type ComponentFunctionProps<Components = ComponentTheme> = {
[Key in keyof Components]?:
| Components[Key]
| ((props: Components[Key]) => Components[Key]);
| ((
props: Components[Key],
theme: Theme & { colors: Colors }
) => Components[Key]);
};

export interface CreateThemeOptions extends RecursivePartial<Theme> {
Expand Down
2 changes: 1 addition & 1 deletion packages/themed/src/config/withTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const ThemedComponent = (
const { components, ...restTheme } = theme;
const themedProps =
typeof components?.[themeKey] === 'function'
? components?.[themeKey]?.(rest)
? components?.[themeKey]?.(rest, restTheme)
: components?.[themeKey];

const newProps = {
Expand Down

0 comments on commit 4caef0c

Please sign in to comment.