rn-css 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/useTheme.d.ts +2 -2
- package/package.json +1 -1
- package/src/useTheme.tsx +3 -3
package/dist/useTheme.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ export declare const ThemeProvider: ({ theme, children }: {
|
|
|
9
9
|
* Returns the Theme
|
|
10
10
|
* @returns The Theme object
|
|
11
11
|
*/
|
|
12
|
-
export declare const useTheme: () =>
|
|
12
|
+
export declare const useTheme: <T extends DefaultTheme = DefaultTheme>() => T;
|
|
13
13
|
/**
|
|
14
14
|
* Adds the theme prop to a non rn-css component
|
|
15
15
|
* @param Component A non rn-css component
|
|
16
16
|
* @returns A component with the theme prop
|
|
17
17
|
*/
|
|
18
|
-
export declare const withTheme: <T>(Component: React.ComponentType<T>) => React.ForwardRefExoticComponent<React.PropsWithoutRef<T> & React.RefAttributes<React.Component<{}, {}, any>>>;
|
|
18
|
+
export declare const withTheme: <T extends DefaultTheme = DefaultTheme>(Component: React.ComponentType<T>) => React.ForwardRefExoticComponent<React.PropsWithoutRef<T> & React.RefAttributes<React.Component<{}, {}, any>>>;
|
package/package.json
CHANGED
package/src/useTheme.tsx
CHANGED
|
@@ -12,16 +12,16 @@ export const ThemeProvider = ({ theme, children }: { theme: DefaultTheme; childr
|
|
|
12
12
|
* Returns the Theme
|
|
13
13
|
* @returns The Theme object
|
|
14
14
|
*/
|
|
15
|
-
export const useTheme = () => React.useContext(SharedValue)
|
|
15
|
+
export const useTheme = <T extends DefaultTheme = DefaultTheme>() => React.useContext(SharedValue) as T
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Adds the theme prop to a non rn-css component
|
|
19
19
|
* @param Component A non rn-css component
|
|
20
20
|
* @returns A component with the theme prop
|
|
21
21
|
*/
|
|
22
|
-
export const withTheme = <T, >(Component: React.ComponentType<T>) => {
|
|
22
|
+
export const withTheme = <T extends DefaultTheme = DefaultTheme, >(Component: React.ComponentType<T>) => {
|
|
23
23
|
const ThemedComponent = React.forwardRef<React.Component, T>((props, ref) => {
|
|
24
|
-
const theme = useTheme()
|
|
24
|
+
const theme = useTheme<T>()
|
|
25
25
|
return <Component ref={ref} theme={theme} {...(props as unknown as T)} />
|
|
26
26
|
})
|
|
27
27
|
ThemedComponent.displayName = 'ThemedComponent'
|