I wanted to use styled-components with TypeScript, but after installing dependencies (types for styled-components, etc.) and after changing the extension of one simple component to .ts, it's informing me that my 'styled.div' component is declared but never read and I have error like this showing on line 8 -
'LoginStyled' refers to value but is being used as a type here.ts(2749)
With .js extension, everything works fine. Here is how component looks like:
import React from "react";
import { Card, CardTitle } from "reactstrap";
import styled from "styled-components";
import LoginForm from "./LoginForm";
function Login({toggleAlert}) {
return (
<LoginStyled>
<Card body inverse className="login-window">
<CardTitle>
<h2>Log in</h2>
</CardTitle>
<LoginForm toggleAlert={toggleAlert} />
</Card>
</LoginStyled>
);
}
export default Login;
const LoginStyled = styled.div`
.login-window {
background-color: #333;
border-color: #333;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
h2 {
text-align: center;
}
`;
.tsx?