-
-
Notifications
You must be signed in to change notification settings - Fork 389
[react-jss] add using theme prop if passed inside useStyles #1482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,17 +25,20 @@ type CreateUseStyles = <Theme: {}>(Styles<Theme>, HookOptions<Theme> | void) => | |
| const createUseStyles: CreateUseStyles = <Theme: {}>(styles, options = {}) => { | ||
| const {index = getSheetIndex(), theming, name, ...sheetOptions} = options | ||
| const ThemeContext = (theming && theming.context) || DefaultThemeContext | ||
|
|
||
| /* eslint-disable no-unused-vars */ | ||
| const useTheme = | ||
| typeof styles === 'function' | ||
| ? // $FlowFixMe[incompatible-return] | ||
| (): Theme => React.useContext(ThemeContext) || noTheme | ||
| (propsTheme?: Theme): Theme => propsTheme || React.useContext(ThemeContext) || noTheme | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A minor detail. But is there a chance
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed in 1b78ac4 |
||
| : // $FlowFixMe[incompatible-return] | ||
| (): Theme => noTheme | ||
| (_?: Theme): Theme => noTheme | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming you've added the unused Something like const useTheme = (theme?: Theme): Theme => typeof styles !== 'function' ? noTheme : theme || React.useContext(ThemeContext) || noTheme;They're both the same type of function, so there should only be a need to switch between the return types (instead of switching between function declarations).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed in 1b78ac4 |
||
| /* eslint-enable no-unused-vars */ | ||
|
|
||
| return function useStyles(data: any) { | ||
| const isFirstMount = React.useRef(true) | ||
| const context = React.useContext(JssContext) | ||
| const theme = useTheme() | ||
| const theme = useTheme(data.theme) | ||
|
|
||
| const [sheet, dynamicRules] = React.useMemo( | ||
| () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have an unused variable somewhere? I'm confused as to why I see this comment. In fact, it appears twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in 1b78ac4