React가 이렇게 매력적인 library인지 5년 전에는 몰랐는데... 뒤늦게 hook-based function component가 된게 신의 한수라고 생각한다.
오늘도 CS는 하지 않았다.
프로젝트 WYIS(Why Your Investments Suck)관련해서 조금씩이라도 UI 만들어보자.
Software Engineering at Google 이라는 책이 호평이던데 찾아서 노션에 정리해보자.
Synchronizing with Effects
Some components need to synchronize with external systems For example, you might want to control a non-React component based on the React state, set up a server connection, or send an analytics log when a component appears on the screen. Effects let you run some code after rendering so that you can synchronize your component with some system outside of React.
useEffect
를 잘 알고 현명하게 사용할 줄 아는 React developer가 되자.You Might Not Need an Effect
Effects are an escape hatch from the React paradigm. They let you "step outside" of React and synchronize your components with some external system lke a non-Reac widget, network, or the Browser DOM. If there is no external system involved (for example, if you want to update a component's state when some props or state change), you shouldn't need an Effect. Removing unnecessary Effects will make your code easier to follow, faster to run, and less error-prone.
useEffect
를 피하는 방법, case가 많은데 어렵다. ㅠㅠ 나중에 다시한번 보자. 실제 프로젝트를 해가면서 하면 더 잘 와닿겠지..Static File Serving
Next.js can serve static files, like images, under a folder called
public
in the root directory. Files insidepublic
can then be referenced by your code starting from the base URL (/
).
For example, if you add an image to
public/me.png
, the following code will acess the image:
import Image from 'next/image';
function Avatar() {
return <Image src="/me.png" alt="me" width="64" height="64" />
}
export default Avatar