Я пытаюсь создать динамический тег со стилизованными компонентами.Тег получен через реквизит.
Это пример кода:
import * as React from 'react';
import styled from 'styled-components';
type ContainerProps = {
children: React.ReactNode,
type?: 'section' | 'div' | 'article',
}
const Container = styled.div`
color: ${props => props.theme.primaryColor};
`;
const Icon = styled.div<ContainerProps>`
background-color: red;
`;
const container: React.FunctionComponent<ContainerProps['children']> = ({ children, type = 'section' }: ContainerProps) => {
return (
<Container>
<{ children }
</Container>
);
};
export default container;
Я пытаюсь добиться того, чтобы тег <Container>
(который сейчас div
)динамическая опора на основе prop.type
.