type Props = {
children: React.ReactNode;
};
function Layout({ children }: Props) {
return (
<>
<Header />
<div>{children}</div>
</>
);
}
npm i —save-dev @types/styled-components
npm i styled-components
import styled from "styled-components";
어딘가에서 import가 가능하며, declare를 통해 해당 변수의 존재와 타입을 알릴 수 있다.
item.d.ts 파일을 생성 후 복붙
declare type items = {
id : string;
title: string;
content: string;
}
hooks.ts 파일을 만든 후 아래 코드 처럼 사용하기
import { TypedUseSelectorHook, useSelector } from "react-redux";
import type { RootState } from "../redux/config/configStore";
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
// 따로 타입지정 없이 customhook 처럼 불러와서 사용 가능
import {useAppSelector} from "../hooks"
const exp = useAppSelector((state) => state.status)