Skip to content

Commit

Permalink
fix: useTheme hook when rainbow prop does not exist in context
Browse files Browse the repository at this point in the history
  • Loading branch information
LeandroTorresSicilia committed Sep 17, 2020
1 parent ea1ddfc commit 8966169
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/libs/hooks/useTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ import defaultTheme from '../../styles/defaultTheme';

export default function useTheme() {
const themeContext = useContext(ThemeContext);
return useMemo(
() =>
return useMemo(() => {
if (themeContext && !themeContext.rainbow) {
themeContext.rainbow = {
...defaultTheme,
...normalizeThemeColors(defaultTheme),
};
}
return (
themeContext || {
rainbow: {
...defaultTheme,
...normalizeThemeColors(defaultTheme),
},
},
[themeContext],
);
}
);
}, [themeContext]);
}

0 comments on commit 8966169

Please sign in to comment.