NextJS Flashcards

1
Q

What are the 3 base components of web development?

A

HTML, CSS, Javascript

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

How is the DOM represented?

A

Javascript representation of HTML

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

Who keeps the DOM and HTML in sync?

A

The browser

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

What is the virtual DOM?

A

a javascript representation of the DOM created by React to allow for faster updates

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

Explain imperative programming vs declarative programming using an example

A

Imperative is like giving recipe instructions to someone to make a pizza.

Declarative is like ordering a pizza without being concerned how its made.

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

is React a declarative or imperative library?

A

declarative

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

What’s an example of a JS compiler?

A

Babel

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

Why do you need to compile your React code?

A

React uses JSX which needs to be compiled into JavaScript.

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

What is a component?

A

React’s tool for UI blocks.

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

What do components return?

A

JSX

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

What is SSR?

A

Server Side Rendering: the HTML of the page is generated on the server at request time

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

What is SSG?

A

Static Site Generation: the page is generated on the server, at build time, and stored in a CDN.

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

What function should you export if you want to generate HTML on the server at request time?

A

getSeverSideProps()

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

What function should you export if you want to generate HTML on the server at build time?

A

getStaticProps()

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

When should you use getServerSideProps()?

A

When you want data to be fetched at request time

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

When should you use getStaticProps()?

A

When the page’s data is available before request time. ie very good for SEO

17
Q

Name 3 ways to serve your app:

A

Origin server, CDN, Edge

18
Q

What’s the command to create a new nextJS app?

A

npx create-next-app

19
Q

Whats the common command to run the app?

A

npm run dev

20
Q

What does CSS Modules automatically generate?

A

unique class names

21
Q

What does CSS Modules allow us to do?

A

CSS Modules allow us to scope styles to components

22
Q

Whats the name of the file to create global CSS?

23
Q

How would you apply a style globally?

A
  • Create a layout component
  • Create a global.css file and make updates there
  • Import global.css to layout
24
Q

Where can you import global CSS files?

A

Only inside pages/_app.js

25
Define hydration
When a page is loaded by the browser and the JS runs
26
Which function do we call to say this: "Hey, this page has some data dependencies — so when you pre-render this page at build time, make sure to resolve them first!”
getStaticProps()
27
Where does getStaticProps run?
server side
28
What function do we call for server side rendering?
getServerSideProps()
29
When is getServerSideProps run?
At request time
30
When should you use getServerSideProps() ?
When you need data that has to be fetched at request time
31
When should you use Client-side rendering?
Private, user-specific pages where SEO is not relevant
32
When does getStaticPaths get called?
on staging: every request on prod: every build