What does the getStaticProps function in Next.js do?

  • It creates a static HTML page without data fetching.
  • It fetches data at build time.
  • It fetches data at server-side and client-side.
  • It retrieves dynamic data at runtime.
The getStaticProps function in Next.js is used to fetch data at build time. It allows you to pre-render pages with data before they are served to the client. This approach improves performance as the data is fetched and generated during the build process, reducing the need for runtime data fetching. It's a key feature for static site generation (SSG) in Next.js.

Your team is experiencing issues with components re-rendering unnecessarily. What immutable state handling technique could help mitigate unnecessary re-renders?

  • Caching
  • Memoization
  • Object.freeze()
  • Prototype-based cloning
Memoization is an immutable state handling technique that can help mitigate unnecessary component re-renders. It involves caching the results of expensive function calls based on their input parameters. When the same input parameters are encountered again, the cached result is returned, reducing the need for re-computation and re-rendering.

For platform-specific code in React Native, you can use filename extensions like .ios.js and ________.

  • .android.js
  • .native.js
  • .platform.js
  • .react.js
In React Native, for platform-specific code, you can use filename extensions like .ios.js for iOS-specific code and .android.js for Android-specific code. These filename extensions allow you to write platform-specific logic in separate files, making it easier to maintain and customize your app's behavior for different platforms. .platform.js, .native.js, and .react.js are not standard extensions for platform-specific code in React Native.

The process by which a service worker takes control of a page and becomes active is known as ________.

  • Activation
  • Initialization
  • Installation
  • Registration
The process by which a service worker takes control of a page and becomes active is known as activation. Service workers go through several lifecycle phases, and activation is the point at which the service worker becomes active and can start intercepting network requests.

Using CSS Modules in React, class names are made locally scoped by default and transformed into a unique ______ during the build process.

  • class
  • hash
  • identifier
  • style
In CSS Modules, class names are indeed made locally scoped by default to avoid naming conflicts. These class names are transformed into unique hashes during the build process, ensuring that they won't clash with other styles elsewhere in the application. So, the correct answer to fill in the blank is "hash."

In styled-components, how can you pass props to your styles?

  • By defining styles in a separate JavaScript file.
  • By passing them as arguments to template literals.
  • By using CSS classes.
  • You can't pass props to styles.
In styled-components, you can pass props to your styles by passing them as arguments to template literals. This allows you to conditionally apply styles based on the props of a component. It's a powerful feature that enables dynamic styling based on the component's state or data, making your UI more flexible and responsive.

In Immutable.js, to apply a function to each item in a List and return a new List, you would use the ________ method.

  • apply()
  • forEach()
  • map()
  • transform()
In Immutable.js, to apply a function to each item in a List and return a new List with the results, you would use the map() method. The map() method creates a new List by applying the provided function to each element of the original List, allowing you to perform transformations on the data while maintaining immutability. This is a common operation when working with collections in Immutable.js, and it's a powerful tool for data manipulation.

In React DevTools, what can the "commit" list help you identify?

  • Components that are candidates for optimization.
  • Recently committed changes in the Redux store.
  • The number of Git commits made to the codebase.
  • Unhandled errors in the application.
The "commit" list in React DevTools helps identify components that are candidates for optimization. These components may have unnecessary re-renders or performance bottlenecks, making them prime targets for optimization efforts. It doesn't relate to Redux changes, errors, or Git commits, as it focuses specifically on React component performance.

What is the primary difference between getServerSideProps and getStaticProps in Next.js?

  • getServerSideProps is used for static content.
  • getServerSideProps retrieves data at build time.
  • getStaticProps fetches data on the client-side.
  • getStaticProps is for server-rendered content.
The primary difference between getServerSideProps and getStaticProps in Next.js is that getServerSideProps retrieves data at runtime on the server during each request, making it suitable for dynamic content. On the other hand, getStaticProps fetches data at build time and is used for pages with data that doesn't change frequently, resulting in faster performance.

The Jest function used to create a mock function is called ________.

  • createFunction
  • createMock
  • jestMock
  • mockFunction
In Jest, to create a mock function, you use the jest.fn() function, which is typically referred to as mockFunction. This function is used to create a mock version of a JavaScript function, allowing you to control its behavior for testing purposes. It's a fundamental part of unit testing with Jest.