Type error:Type '{ color: string; loading: true; css: string; size: number; }'is not assignable to type 'IntrinsicAttributes & LoaderSizeMarginProps'

Viewed 14

when I tried to build the project

yarn run build

I got this error

$ yarn run build
yarn run v1.22.19
$ next build
info  - Loaded env from D:\folder_1\my_Project\client\.env.local
info  - Linting and checking validity of types .Failed to compile.

./components/profile/mintingModal/LoadingState.tsx:28:49
Type error: Type '{ color: string; loading: true; css: string; size: number; }' 
is not assignable to type 'IntrinsicAttributes & LoaderSizeMarginProps'.
  Property 'css' does not exist on type 'IntrinsicAttributes & LoaderSizeMarginProps'.

  26 |     <div className={style.wrapper}>
  27 |       <div className={style.title}>Minting in progress...</div>
> 28 |       <GridLoader color={'#fff'} loading={true} css={subtitleStyle} size={30} />
     |                                                 ^
  29 |     </div>
  30 |   )
  31 | }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

and this is the LodaingState.tsx file that the error appear into it

import { GridLoader } from 'react-spinners'
import { css } from '@emotion/react'

const style = {
  wrapper: `h-[20rem] w-[35rem] text-white bg-[#15202b] rounded-3xl p-10 flex flex-col items-center justify-center`,
  title: `font-semibold text-xl mb-6`,
}

const cssOverride = css`
  display: block;
  margin: 0 auto;
  border-color: white;
`

const LoadingState = () => {
  return (
    <div className={style.wrapper}>
      <div className={style.title}>Minting in progress...</div>
      <GridLoader color={'#fff'} loading={true} css= {cssOverride} size={30} />
    </div>
  )
}

export default LoadingState

2 Answers

This is a typo.

Because you are tying to put the cssOverride object in the css attribute of the GridLoader but the cssOverride object TYPE does not match with the type necesary for the css attribute("IntrinsicAttributes & LoaderSizeMarginProps") in the GridLoader Component.

Can you show the GridLoader.tsx file yo help more extensive in this solution?

I have tried to rename the file to be LodaingState.js instead of LodaingState.tsx and it works, :) and the error disappeared, but unfortunately, I don't understand why!!

Related