Skip to content

Commit

Permalink
refactor: avoid defaultProps for styled-components
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed May 18, 2024
1 parent 6a4d273 commit d782453
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
8 changes: 2 additions & 6 deletions src/components/elements/Heading.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styled from 'styled-components'
import { theme } from 'theme'
import React from 'react'

import Text from './Text'

Expand All @@ -13,9 +14,4 @@ const Heading = styled(Text)(
})
)

Heading.defaultProps = {
as: 'h1',
variant: 'gradient'
}

export default Heading
export default props => <Heading as='h1' variant='gradient' {...props} />
8 changes: 2 additions & 6 deletions src/components/elements/Subhead.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from 'styled-components'
import Heading from './Heading'
import { theme } from 'theme'
import React from 'react'

const Subhead = styled(Heading)(
theme({
Expand All @@ -9,9 +10,4 @@ const Subhead = styled(Heading)(
})
)

Subhead.defaultProps = {
as: 'h2',
variant: null
}

export default Subhead
export default props => <Subhead as='h2' variant={null} {...props} />
4 changes: 0 additions & 4 deletions src/components/elements/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@ const Text = styled(Box).withConfig({
})
)

Text.defaultProps = {
as: 'div'
}

export default Text

0 comments on commit d782453

Please sign in to comment.