File tree Expand file tree Collapse file tree 4 files changed +13
-1
lines changed
.changeset/dirty-owls-remain
packages/emotion-theming/types Expand file tree Collapse file tree 4 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "releases" : [{ "name" : " emotion-theming" , "type" : " patch" }],
3+ "dependents" : []
4+ }
Original file line number Diff line number Diff line change 1+ Add TypeScript type definition for the useTheme hook in emotion-theming
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ export function ThemeProvider<Theme>(
1414 props : ThemeProviderProps < Theme >
1515) : React . ReactElement
1616
17+ export function useTheme < Theme > ( ) : Theme
18+
1719/**
1820 * @todo Add more constraint to C so that
1921 * this function only accepts components with theme props.
Original file line number Diff line number Diff line change 11import * as emotionTheming from 'emotion-theming'
22import * as React from 'react'
33
4- const { ThemeProvider, withTheme } = emotionTheming
4+ const { ThemeProvider, withTheme, useTheme } = emotionTheming
55
66interface Theme {
77 primary : string
@@ -38,6 +38,11 @@ class CompCWithDefault extends React.Component<Props> {
3838 }
3939}
4040
41+ {
42+ const theme : Theme = useTheme < Theme > ( )
43+ const themeFail : Theme = useTheme < number > ( ) // $ExpectError
44+ }
45+
4146const ThemedSFCWithDefault = withTheme ( CompSFCWithDefault )
4247; < ThemedSFCWithDefault />
4348; < ThemedSFCWithDefault theme = { theme } />
You can’t perform that action at this time.
0 commit comments