Search code examples
reactjstypescriptstyled-componentsreact-typescript

Styled-components suggestion props name with type script


I need styled-components show suggestion props name I create styled components CardHeader and add props

interface ICardHeader { darkMode?:boolean }

enter image description here

enter image description here

code is working but componen not show darkMode suggestion props


Solution

  • You can try this little lifehack

    import { FC } from 'react';
    
    const CardHeader = styled<FC>(Card.Header)<ICardHeader>``
    

    but for good, you just need to type the component (seemd it's just any and that's why types don't work correctly) from this library and everything will work