propsが一つの場合
type Props = {
props: DataType
propsTwo: Boolean
}
type DataType = {
id: Number
icon: String
props: String
}
const Example = ({props}: Props) => (
<ExampleStyle backgroundColor={props.propsOne}>
</ExampleStyle>
)
const ExampleStyle = styled.div<{backgroundColor: String}>`
background-color: ${({backgroundColor}) => `${backgroundColor}`};
`
propsが二つの場合
type Props = {
props: DataType
propsTwo: Boolean
}
type DataType = {
id: Number
icon: String
props: String
}
type StyleProps = {
backgroundColor: String
propsTwo: Boolean
}
const Example = ({props, propsTwo}: Props) => (
<ExampleStyle backgroundColor={props.propsOne} propsTwo={propsTwo}>
</ExampleStyle>
)
const ExampleStyle = styled.div<StyleProps>`
background-color: ${({backgroundColor}) => `${backgroundColor}`};
opacity: ${({propsTwo}) => propsTwo && 0.5};
`
参考にした資料