โ† All React Flashcard Decks

Introducing React Hooks Flashcards

6 cards from real React practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 Introducing React Hooks flashcards as text
  1. What exactly are Hooks?

    Answer: Javascript functions

    React Hooks are essentially JavaScript functions that allow you to 'hook into' React state and lifecycle features directly from function components. They provide a way to manage state, perform side effects, and access context without needing to write class components. Examples include `useState`, `useEffect`, and `useContext`.

  2. Choose which is not an in-build hook.

    Answer: useFetch

    Among the options, `useState`, `useRef`, and `useEffect` are all built-in React Hooks provided by the React library. `useFetch` is not a standard built-in Hook; while it's a common pattern for data fetching and often implemented as a custom hook or found in third-party libraries, it is not part of the core React API.

  3. When do the states initialize in lifecycles?

    Answer: Mounting

    In React's component lifecycle, states are initialized during the 'mounting' phase. This is the stage when a component is first created and inserted into the DOM. For instance, the `useState` hook initializes its state with the provided initial value only when the component first renders and mounts.

  4. Which won't force the component to re-render?

    Answer: Changes in .current of useRef

    Changes to the `.current` property of a `useRef` hook do not trigger a re-render of the component. `useRef` is primarily used to persist mutable values across renders or to access DOM elements directly without causing the component to update. Only changes to state, props, or the dependency array of `useEffect` (which can indirectly cause state changes) will force a component to re-render.

  5. ReactJS may be incorporated into any current web application.

    Answer: True

    ReactJS is designed for incremental adoption, meaning it can be seamlessly integrated into existing web applications without requiring a complete rewrite. You can render React components within specific parts of an existing HTML page, allowing you to gradually introduce React functionality or use it for particular UI elements alongside other technologies.

  6. To create UI elements, ReactJS does not require HTML or any HTML preprocessors.

    Answer: False

    ReactJS primarily uses JSX (JavaScript XML), which is a syntax extension that allows developers to write HTML-like code directly within JavaScript. While JSX is not raw HTML, it is a preprocessor that gets compiled into `React.createElement()` calls, effectively requiring an HTML-like structure to define UI elements. Therefore, it does require an understanding of HTML-like syntax and a JSX compiler.

Written and edited by , founder of Practice Test Geeks, with AI assistance. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Editorial policy