React Flashcards
(5 cards)
What is the command to create or run a Next JS Project?
npx create-next-app@latest
npm run dev
What options are given when setting up a Next JS project?
- project name
- Typescript or Js
- ESLint
- Tailwind
- App Router (new) or pages router
What are the Next scripts?
- dev (runs dev server)
- build (builds app for production)
- start (starts the production server)
- lint (runs ESLint)
What is the role of useEffect in React?
useEffect is a built-in React hook that lets you run side effects in function components. It is commonly used for 1) fetching data when a component mounts, 2) listening for state or prop changes and reacting accordingly, and 3) setting up and cleaning up subscriptions or timers.
You can control when the effect runs by passing a second argument into the dependency array. [] runs on mount, [state] runs on state change, and no array runs on every render (rarely needed).
It can lead to unnecessary re-renders or spaghetti logic