I cannot find another way to give my props dynamic styles without creating the styled-component inside the Text component. For performance I'd like to create the component outside of the Text component.
Styled Component
import React, { ReactChildren } from 'react'
import styled from 'styled-components'
export const Text = ({ as = 'p', children, styles = {} }) => {
const newStyles = Object.entries(styles).reduce((acc, [key, value]) => {
return `${acc}${key}: ${value};`
}, '')
const Component = styled.p`
${newStyles}
color: #000;
`
return <Component as={as}>{children}</Component>
}
Desired Usage
<Text styles={{ height: "10px" }} />
Output HTML
<p styles="height: 10px" />

