TS2322 - is not assignable to type

Viewed 32

I`m trying to update a 4 pages layout contents, and i think the problem is in this component.

I`m getting an error:

Type '(props: any) => ReactNode' is not assignable to type 'ReactNode'

When i change to const Home: React.ReactElement

ERROR in src/pages/Home.tsx:25:12

TS2552: Cannot find name 'ReactElement'. Did you mean 'SVGRectElement'?
    23 |
    24 |
  > 25 | const Home:ReactElement = (props) => {
       |            ^^^^^^^^^^^^
    26 |   const { routes } = useTransistorInit()
    27 |   const [element, setElement] = useState<React.ReactNode>()
    28 |   const el = (<>


ERROR in src/pages/Home.tsx:25:28

TS7006: Parameter 'props' implicitly has an 'any' type.
    23 |
    24 |
  > 25 | const Home:ReactElement = (props) => {
       |                            ^^^^^
    26 |   const { routes } = useTransistorInit()
    27 |   const [element, setElement] = useState<React.ReactNode>()
    28 |   const el = (<>

Home.tsx

const Home:React.ReactNode = (props) => {
  const { routes } = useTransistorInit()
  const [element, setElement] = useState<React.ReactNode>()
  const el = (<>
    <CenterPage  />
    <LeftPage    />
    <RightPage   />
    <BottonPage  />
  </>)

  useEffect(()=> {

      setElement(el)

    
  },[routes])
  return element
}

export default Home

How to resolve this issue

0 Answers
Related