Everyday
Every Morning
PS1
https://github.com/zacanger/styled-reset/blob/master/src/index.ts reset
source sans pro 폰트
https://coinicons-api.vercel.app/ 코인 icon api
https://www.online-toolz.com/tools/unicode-html-entities-convertor.php entity 변환
styled-component-> 가독성에 굿 / 조금 더 많이 써보기
<Link></Link>
이거 css 는 a 태그에
특정한 시점에만 코드실행 => useEffect
useEffect(()=>{
(()=>console.log(2))() // 바로실행되는 함수
},[])
useEffect(()=>{
(async()=>{
const response =await fetch(url);
const json = await response.json();
console.log(json);
})()
},[])
=> react query로 대체하기
array.slice(시작, 갯수)
리액트 Link state 실어 보내기
https://v5.reactrouter.com/web/api/Link
https://typescript.tv/react/upgrade-to-react-router-v6/
import { useParams } from "react-router-dom";
interface RouteParams {
coinId: string;
}
interface LocationParams {
state: {
name: string;
rank: number;
};
}
function Coin() {
const { coinId } = useParams<keyof RouteParams>() as RouteParams;
const { state } = useLocation() as LocationParams;
return (
<div>
<h1>Coin: {coinId} {state}</h1>
</div>
);
}
export default Coin;
코드 줄이기
useEffect(()=>{
(async()=>{
const firstData =await (await fetch(url)).json();
const secondData = await (await fetch(url)).json();
setFirstData(firstData);
setSecondData(secondData);
})()
},[])
PS2
backend rest apis - crud
router.get("/", (req,res,next)=>{
const username = req.query.username;
const data = username? posts.filter(post=>post.username === username) : posts;
res.status(200).json(data);
})
router.get("/:id", (req,res,next)=>{
const id = req.params.id;
const post = posts.find((post)=>post.id ===id)
if(post){
res.status(200).json(post)
}else {
res.status(404).json({message: `Post id(${id}) not found` });
}
})
router.post("/:id", (req,res,next)=>{
const {text,name,username } =req.body;
const post = {
id:Date.now()
text,
createdAt: new Date(),
name,
username
}
posts = [post, ...posts];
res.status(201).json(post);
})
router.put("/:id", (req,res,next)=>{
const id = req.params.id;
const text = req.body.text
post = posts.fine(post => post.id ===id);
if(post){
post.text=text;
res.status(200).json(post)
}else {
res.status(404).json({message: `Post id(${id}) not found` });
}
})
router.delete("/:id", (req,res,next)=>{
const req.params.id;
posts = posts.filter(post => post.id !==id);
res.sendStatus(204);
})
데이터베이스로~ / 프엔 구현
Monday/ Wednesday/ Thursday (Clarisse랑 날짜 조정하기)
Wednesday/ Saturday
Free time