2

Почему выдается ошибка "'DesktopSize' cannot be used as a JSX component.   Its return type 'ReactNode' is not a valid JSX element."? По разному пытался, не исчезает.

interface ResponsiveProps {
  children: React.ReactNode | null
}

export const DesktopSize = ({ children }: ResponsiveProps) => {
  const isNotMobile = true
  return isNotMobile ? children : null

}

const TestComponent = () => {
  return <div>
    <DesktopSize>
      <div>
        <h1>hello</h1>
      </div>
    </DesktopSize>
  </div>
}

1 ответ 1

0

Вместо React.ReactNode укажите JSX.Element.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.