React Flashcards

(5 cards)

1
Q

What is the command to create or run a Next JS Project?

A

npx create-next-app@latest
npm run dev

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What options are given when setting up a Next JS project?

A
  • project name
  • Typescript or Js
  • ESLint
  • Tailwind
  • App Router (new) or pages router
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the Next scripts?

A
  • dev (runs dev server)
  • build (builds app for production)
  • start (starts the production server)
  • lint (runs ESLint)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the role of useEffect in React?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly