react interview questions part 3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

List down the advantages of ReactRouter.

- allows us to build a single-page web application with navigation without the page refreshing as the user navigates

What is React Router?

-React Router, and dynamic, client-side routing, allows us to build a single-page web application with navigation without the page refreshing as the user navigates. -React Router uses component structure to call components, which display the appropriate information.

Why is Switch component used in React Router v4?

-The <Switch /> component will only render the first route that matches/includes the path. - Once it finds the first route that matches the path, it will not look for any other matches. -Not only that, it allows for nested routes to work properly, which is something that <Router /> will not be able to handle.

What is a constructor? Is it required?

-The constructor is a method that's automatically called during the creation of an object from a class. -It can handle your initial setup stuff like defaulting some properties of the object, or sanity checking the arguments that were passed in. -Simply put, the constructor aids in constructing things. -In React, the constructor is no different. It can be used to bind event handlers to the component and/or initializing the local state of the component.

What is React.memo

-memo is a higher order component. If your component renders the same result given the same props, you can wrap it in a call to React. memo for a performance boost in some cases by memorizing the result.-This means that React will skip rendering the component, and reuse the last rendered result.

How is React Router different from conventional routing?

-the Routing is taking place while react app is rendering. It allows us to build a single-page web application with navigation without the page refreshing(preventing page refresh/white screen) as the user navigates. It uses component structure to call components.

What is the significance of keys in React?

A "key" is a special string attribute you need to include when creating lists of elements in React. -Keys are used in React to identify which items in the list are changed, updated or deleted

What is the difference of calling a promise and using a `.then` vs using `await`

The fundamental difference between await and vanilla promises is that await X() suspends execution of the current function, while promise. then(X) continues execution of the current function after adding the X call to the callback chain. In the context of stack traces, this difference is pretty significant.

In package.json, how can you ensure that only patch version updates are accepted when npm install is run? (i.e. upgrading from 2.3.0 to 2.3.1 is okay, but not 2.4.0 or greater)

To ensure you are only updating to the exact version of the dependency, you can specify the exact version by changing the npm config with save-exact : npm config set save-exact tru

Why do we need a Router in React?

We need a Router in React to allows us to build web applications with navigation without the page refreshing as the user navigates. - Uses component structure to call components and display the appropriate information


Set pelajaran terkait

Prep u health assessment chapter 14

View Set

3 mechanisms that contribute to hemostasis and blood clotting

View Set

AP Chemistry, Chapter 7: Atomic Structure and Periodicity (This quizlet includes ALL periodic trends, however, for testing purposes, know that: Chapter 7 primarily covers half of the trends, while Chapter 8 covers the other half of the trends)

View Set