Skip to content

Commit 0b8a6de

Browse files
committed
Remove Options from useStyle(Not Necessary)
1 parent faf2dd2 commit 0b8a6de

File tree

5 files changed

+7
-26
lines changed

5 files changed

+7
-26
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,13 @@ A react component to provide ThemeContext.
174174

175175
---
176176

177-
### Function: `useStyle(createStyles, [options])`
177+
### Function: `useStyle(createStyles)`
178178

179179
Hook to create themed stylesheets.
180180

181181
**Parameters**
182182

183183
- `createStyles`: A function that receives the current theme and options and returns an object of type `T`.
184-
- `options`: Custom options to be used inside createStyles.
185184

186185
**Returns**
187186

index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ type UseTheme<T, C> = () => ThemeContext<T, C>
2525
type ThemeObject = {
2626
[props: string]: ViewStyle | TextStyle | ImageStyle
2727
}
28-
type UseStyle<T, C> = <S extends ThemeObject, O>(
29-
createStyleSheet: (theme: T & C, options?: O) => S,
30-
options?: O
28+
type UseStyle<T, C> = <S extends ThemeObject>(
29+
createStyleSheet: (theme: T & C) => S
3130
) => StyleSheet.NamedStyles<S>
3231
type CreateTheme = <T, C>(
3332
themes: Themes<T, C | undefined>,
@@ -108,9 +107,9 @@ const createTheme: CreateTheme = (ts, initialMode = 'auto') => {
108107
)
109108

110109
const useTheme: UseTheme<Theme, Common> = () => useContext(ThemeContext)
111-
const useStyle: UseStyle<Theme, Common> = (createStyledObject, options) => {
110+
const useStyle: UseStyle<Theme, Common> = createStyledObject => {
112111
const { theme } = useTheme()
113-
return StyleSheet.create(createStyledObject(theme, options))
112+
return StyleSheet.create(createStyledObject(theme))
114113
}
115114

116115
return { ThemeProvider, useStyle, useTheme }

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-themed-stylesheet",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"description": "React Native StyleSheets with Theming Support",
55
"author": "Andre Pedroza",
66
"license": "MIT",

tests/fixture.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,3 @@ export const style2 = (theme: typeof themes2.light) => ({
3434
color: theme.textColor
3535
}
3636
})
37-
38-
export const style3 = (
39-
theme: typeof themes1.common & typeof themes1.light,
40-
options?: { disabled: boolean }
41-
) => ({
42-
text: {
43-
color: options && options.disabled ? '#c0c0c0' : theme.textColor,
44-
fontSize: theme.fontSize
45-
}
46-
})

tests/tests.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { renderHook, act } from '@testing-library/react-hooks/native'
22
import { Appearance } from '../__mocks__/react-native-appearance'
33
import { createTheme } from '..'
4-
import { style1, style2, style3, themes1, themes2 } from './fixture'
4+
import { style1, style2, themes1, themes2 } from './fixture'
55
import { TextStyle } from 'react-native'
66

77
beforeEach(() => {
@@ -17,13 +17,6 @@ describe('With Common Prop and Auto Mode', () => {
1717
expect((result.current.text as TextStyle).color).toEqual('#ff0000')
1818
expect((result.current.text as TextStyle).fontSize).toEqual(12)
1919
})
20-
test('Create style with useStyle() and options', () => {
21-
const { result } = renderHook(() => useStyle(style3, { disabled: true }), {
22-
wrapper: ThemeProvider
23-
})
24-
expect((result.current.text as TextStyle).color).toEqual('#c0c0c0')
25-
expect((result.current.text as TextStyle).fontSize).toEqual(12)
26-
})
2720
test('Create style with useTheme()', () => {
2821
const { result } = renderHook(() => useTheme(), { wrapper: ThemeProvider })
2922
expect(result.current.theme.textColor).toEqual('#ff0000')

0 commit comments

Comments
 (0)