<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: techie swastika </title>
    <description>The latest articles on DEV Community by techie swastika  (@techie-swastika).</description>
    <link>https://dev.to/techie-swastika</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1843934%2Fe32d2f70-41e7-4db7-a418-386eed749bae.png</url>
      <title>DEV Community: techie swastika </title>
      <link>https://dev.to/techie-swastika</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/techie-swastika"/>
    <language>en</language>
    <item>
      <title>React.js interview questions with answers Part-1</title>
      <dc:creator>techie swastika </dc:creator>
      <pubDate>Fri, 26 Jul 2024 12:44:46 +0000</pubDate>
      <link>https://dev.to/techie-swastika/reactjs-interview-questions-with-answers-part-1-meo</link>
      <guid>https://dev.to/techie-swastika/reactjs-interview-questions-with-answers-part-1-meo</guid>
      <description>&lt;p&gt;1.What are React hooks?&lt;/p&gt;

&lt;p&gt;Ans: React Hooks are functions that allow functional components in React to have state, lifecycle methods, and other functionality that was previously only available to class components. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Explain the useEffect hook ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: useEffect is a hook to perform side effects in functional components. It runs on every render and can be used to fetch data, subscribe, manually modify the DOM etc. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is the useState hook ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: The useState hook in React is used to add state variables to functional components so that they can track state changes and trigger re-renders.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is the purpose of useReducer hook ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: useReducer is a hook in React used for state management. It is suitable for managing complex state logic with multiple sub-values or when the next status depends on the previous status.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is the purpose of useCallback hook in React ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: useCallback is used to store callback functions and prevent unnecessary re-rendering of child components that depend on these callbacks.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Explain the concept of Hook rules in React ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: The rules for using Hooks in React include that they are called at the top level, they are called only from function components or custom Hooks, and they follow a naming convention. For example- starting with “use”. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is the purpose of useMemo hook in React ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: useMemo hook is used to store the results of calculations. It helps in performance optimization by preventing unnecessary recalculations.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is the importance of useRef hook in React ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: useRef is used to create mutable object properties that persist across multiple renders without re-rendering when a change occurs. It is often used to access and change properties of DOM elements.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is PureComponent in React ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: PureComponent is a base class for class components that implements the shouldComponentUpdate method to do superficial property and state comparisons. This helps prevent unnecessary rendering for performance optimization.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What are React Fragments ? &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: React Fragments allow you to group multiple elements together without adding unnecessary nodes to the DOM. This is useful when you don’t want to introduce an additional parent div.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is the importance of keys in React lists ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: Keys are used to help React detect which items in the list have changed, added, or removed. They help optimize the rendering process.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is React’s Context API ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: The Context API provides a way to pass data through a component tree without having to manually pass props at each level.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How does React Prop handle drilling ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: Prop drilling occurs when you route a prop to multiple component levels. The solution is to use Context API or Redux for global state management.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is the importance of keys in React lists ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: Keys are used to help React detect which items in the list have been changed, added, or removed. They help in optimizing the rendering process. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Explain the concept of lazy loading in React ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: Lazy loading is a technique where a component or resource is loaded only when it is actually required. React provides the React.lazy feature to lazily load components.&lt;/p&gt;

</description>
      <category>react</category>
      <category>interview</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
