Greetings! As a newcomer to typescript, I find myself with a query regarding the use of Theme in emotionJs. Here's the snippet of code that has been causing me some trouble:
const GlobalStyle: React.FC = (props) => {
const Theme = useTheme();
return (
<Global
styles={css`
@import url('https://fonts.googleapis.com/css?family=Poppins&display=swap');
@import url('https://fonts.googleapis.com/css?family=Roboto&display=swap');
/* Rest of the CSS properties */
body {
background: ${Theme.colors.background};
color: ${Theme.colors.text};
transition-duration: 0.4s;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
'Oxygen', 'Ubuntu', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
}
`}
/>
);
};
Unfortunately, when running this code, I encountered the following error:
Object is of type 'unknown'.ts(2571)
This issue seems to stem from the uncertainty around declaring the type for my constant Theme while using useTheme.
I am aware that specifying the type for the theme variable is where the problem lies, but I'm uncertain about the correct approach to resolve this dilemma. Any guidance on this matter would be greatly appreciated!