programing

유형 '{}'을(를) 유형 'ReactNode'에 할당할 수 없습니다.

css3 2023. 3. 6. 21:20

유형 '{}'을(를) 유형 'ReactNode'에 할당할 수 없습니다.

이 오류는 발생했지만 Vercel에서만 발생하며 로컬에서는 발생하지 않습니다. 왜일까요?

error: 'FontAwesomeIcon' cannot be used as a JSX component.
./components/Services/ServiceContainer.tsx:25:6
12:01:54.967    Type error: 'FontAwesomeIcon' cannot be used as a JSX component.
12:01:54.967      Its element type 'ReactElement<any, any> | Component<FontAwesomeIconProps, any, any>' is not a valid JSX element.
12:01:54.968        Type 'Component<FontAwesomeIconProps, any, any>' is not assignable to type 'Element | ElementClass'.
12:01:54.968          Type 'Component<FontAwesomeIconProps, any, any>' is not assignable to type 'ElementClass'.
12:01:54.968            The types returned by 'render()' are incompatible between these types.
12:01:54.968              Type 'React.ReactNode' is not assignable to type 'import("/vercel/path0/node_modules/@types/styled-jsx/node_modules/@types/react/index").ReactNode'.
12:01:54.968                Type '{}' is not assignable to type 'ReactNode'.
import Head from 'next/head'
import Image from 'next/image'
import styles from '../../styles/Services/ServiceContainer.module.css'
import { IconProp } from '@fortawesome/fontawesome-svg-core'
import dynamic from 'next/dynamic'
const FontAwesomeIcon = dynamic(
    async () => (await import('@fortawesome/react-fontawesome')).FontAwesomeIcon
)

export default function ServiceContainer(props: {
    title: string
    list?: string[]
    icon: IconProp
    text?: string
    isContainerNarrow?: boolean
}) {
    const { title, list, icon, text, isContainerNarrow } = props
    return (
        <div
            className={`${styles.serviceBoxContainer} ${
                isContainerNarrow ? styles.narrow : styles.wide
            }`}
        >
            <div className={styles.serviceBox}>
                <FontAwesomeIcon icon={icon} className={styles.icon} />
                <div className={styles.serviceBoxInner}>
                    <h2 className={'h2_2'}>{title}</h2>
                    {list && (
                        <ul>
                            {list.map((listItem: string) => (
                                <li key={listItem}>{listItem}</li>
                            ))}
                        </ul>
                    )}
                    {text && <p>{text}</p>}
                </div>
            </div>
        </div>
    )
}
{
    "dependencies": {
        "@date-io/date-fns": "^1.3.13",
        "@fortawesome/fontawesome-common-types": "^6.1.1",
        "@fortawesome/fontawesome-svg-core": "^6.1.1",
        "@fortawesome/free-solid-svg-icons": "^6.1.1",
        "@fortawesome/react-fontawesome": "^0.1.18",

지난주부터 큰 변경 없이 빌드 서버에서 이 문제가 발생하기 시작했는데, 아직 수정 방법을 찾지 못했습니다.그러나 다른 팀에서 이 오류와 관련된 갑작스러운 문제가 발생하여 발생한 문제가 몇 가지 있습니다.

문제는 React GitHub 페이지에서 확인하시고, 이 문제는 Redwoodjs GitHub 페이지에서 확인하시기 바랍니다.

갱신하다

Yeven Rybak의 답변은 우리에게 효과가 있었다.

또 다른 것도 추가했습니다.preinstall scriptSahil Patel의 대답에서.

언급URL : https://stackoverflow.com/questions/71852153/type-is-not-assignable-to-type-reactnode