Skip to content

Commit

Permalink
dont append theme to props
Browse files Browse the repository at this point in the history
  • Loading branch information
robinweser committed Feb 23, 2022
1 parent 57eed0b commit def8f25
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/react-fela/src/useFela.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@ import { combineRules } from 'fela'

import { RendererContext, ThemeContext } from './context'

export default function useFela(props = {}) {
function getPropsWithTheme(props, theme) {
if (props) {
return {
...props,
theme,
}
}

return {
theme,
}
}

export default function useFela(props) {
const renderer = useContext(RendererContext)
const theme = useContext(ThemeContext) || {}

Expand All @@ -14,10 +27,7 @@ export default function useFela(props = {}) {
}

// we add the theme to props so that it can be used within styles
const propsWithTheme = {
...props,
theme,
}
const propsWithTheme = getPropsWithTheme(props, theme)

function css(...rules) {
return renderer.renderRule(combineRules(...rules), propsWithTheme)
Expand Down

1 comment on commit def8f25

@vercel
Copy link

@vercel vercel bot commented on def8f25 Feb 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.