Skip to content

Commit

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

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

function getPropsWithTheme(props, theme) {
// if props is not a direct copy of React props
// we can simply add the theme to it for perf reasons
if (Object.isExtensible(props)) {
props.theme = theme
return props
}

return {
...props,
theme,
}
}

export default function useFela(props = {}) {
const renderer = useContext(RendererContext)
const theme = useContext(ThemeContext) || {}
Expand All @@ -28,7 +14,10 @@ export default function useFela(props = {}) {
}

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

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

1 comment on commit 57eed0b

@vercel
Copy link

@vercel vercel bot commented on 57eed0b 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.