Сценарий:
Я создаю текстовый компонент; в него встроен еще один компонент Tag.
Вопрос:
Как я могу набрать его, чтобы он работал? Теперь появляется ошибка, и она не принимает желаемые стили.
Ошибка заключается в следующем:
Type '{ children: ReactNode; classNames: any; }' is not assignable to type 'IntrinsicAttributes'. Property 'children' does not exist on type 'IntrinsicAttributes'.ts(2322)
Это мой код:
import React, { ReactNode } from 'react';
import styles from './Text.module.css';
import classNames from 'classnames/bind';
const cx = classNames.bind(styles);
interface ITextProps {
variant: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p1' | 'p2' | 'p3';
bold?: boolean;
}
const tags = {
h1: 'h1',
h2: 'h2',
h3: 'h3',
h4: 'h4',
h5: 'h5',
h6: 'h6',
p1: 'p',
p2: 'p',
p3: 'p',
};
const Text: React.FC<ITextProps> = ({ children, variant, bold }) => {
const Tag = tags[variant];
return <Tag classNames={cx({ title: variant === 'h1' })}>{children}</Tag>;
};
export default Text;