Skip to content

Commit

Permalink
Fix Flow type for withTheme (#1397)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonC authored and emmatown committed Jun 12, 2019
1 parent 62576aa commit 3380373
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .changeset/thick-brooms-yell/changes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"releases": [{ "name": "emotion-theming", "type": "patch" }],
"dependents": []
}
1 change: 1 addition & 0 deletions .changeset/thick-brooms-yell/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixing flow types for the withTheme HOC
1 change: 1 addition & 0 deletions packages/emotion-theming/__tests__/with-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test(`withTheme(Comp) hoists non-react static class properties`, () => {
const ComponentWithTheme = withTheme(ExampleComponent)

expect(ComponentWithTheme.displayName).toBe('WithTheme(foo)')
// $FlowFixMe
expect(ComponentWithTheme.someSpecialStatic).toBe(
ExampleComponent.someSpecialStatic
)
Expand Down
6 changes: 3 additions & 3 deletions packages/emotion-theming/src/with-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ type Props = { theme: Object }

// should we change this to be forwardRef/withCSSContext style so it doesn't merge with props?

const withTheme = (Component: React.ComponentType<Props>) => {
export default function withTheme<Config: {}>(
Component: React.AbstractComponent<Config>
): React.AbstractComponent<$Diff<Config, Props>> {
const componentName = Component.displayName || Component.name || 'Component'
let render = (props, ref) => {
return (
Expand All @@ -25,5 +27,3 @@ const withTheme = (Component: React.ComponentType<Props>) => {

return hoistNonReactStatics(WithTheme, Component)
}

export default withTheme

0 comments on commit 3380373

Please sign in to comment.