Posts

Showing posts from December, 2024

reactjs questions part 4

A prop change does not re-render a component if the prop is stored as a local variable. It only re-renders when the prop is stored as a state variable. =======  I take 2-3 interviews per week on average for react devs. The most common one I ask my candidates is this: Explain how react works under the hood to me like I'm 5 yr old What problem did react come to solve? What are composable components? How do you separate logic and style? What are the security measures to be taken to avoid data leak in frontend TYPESCRIPT specific How do you validate form input data  How do you design typesafe components GENERAL what are accessible components, how do you design them ? State management - redux vs context API.  --------------------------2------------------------------- Here are some key API-related questions to prepare for your React.js interview: API Calls and Data Manipulation How do you make API calls in a React application and handle the response data? What is the best pract...

reactjs question aprt 3

  I hope this helps: https://github.com/sudheerj/reactjs-interview-questions https://github.com/yangshun/tech-interview-handbook https://github.com/jwasham/coding-interview-university/tree/main https://github.com/DopplerHQ/awesome-interview-questions#reactjs https://github.com/enaqx/awesome-react Thanks everyone!! The interview went awesome. They asked some scenario questions rather than how to code this or that. Some questions they asked were: state management, what you use and why CSS framework and could you make it responsive and how How react interact with DOM Any library used for forms?? And why Any library related to tables - I said react-table and why I used it Git rebase why typescript some scenario questions ⁉️ APIs and what you use for it  ------------------------------------------------------ A question I haven't really seen raised, which I both ask and have seen being asked before: what problem does async/await syntax solve and what other kinds of approaches to asy...

reactjs questions part 2

 1 How memoization works, and when/why it should be used 2 The virtual DOM. What it is, and how React uses it to update the actual DOM 3 How keys are used in lists, and why they should be stable and unique 4 Describing the lifecycle of a React component 5 How useEffect actually works, and when you do and don't need to use it 6 How hooks work, and why you would want to encapsulate business logic in a custom hook 7 I would also be prepared to discuss dependency arrays (specifically for hooks that will produce side effect such as useEffect and custom hooks that update some value) and why you need to be very discerning with what you include in these arrays 8 I mention specific hooks because generally speaking, hooks that return a function or a computed value (useCallback/useMemo) should use exhaustive dependencies, whereas hooks that update something without direct user interaction need to be tightly controlled * how to pass data btwn siblings, know how to fetch data and render to a li...

Q: Error Boundary in React that catches an error and displays a fallback UI

ErrorBoundary Component : This catches errors in its child components and displays a fallback UI ( Something went wrong. ). MyComponent : This component intentionally throws an error to demonstrate how the error boundary works. App Component : Wraps  MyComponent  with  ErrorBoundary  to catch and handle errors  When you run this code, you'll see "Something went wrong." displayed on the screen because MyComponent throws an error, which is caught by the ErrorBoundary .  CREATING SAMPLE: Let's create a simple example of an error boundary in React that catches an error and displays a fallback UI when an error occurs in a component. 1.ErrorBoundary Component import React , { Component } from " react " ; class ErrorBoundary extends Component {   constructor ( props ) {     super ( props ) ;     this . state = { hasError : false } ;   }   static getDerivedStateFromError ( error ) {     ...

reactjs questions---https://bigfrontend.dev/react-quiz

https://bigfrontend.dev/react-quiz 1. Can you explain a novice the difference between state and props? 2. When will you use state, context, and external state manager? 3. How do you decide when to split a component into subcomponents? 4. How do you handle API and what techniques you'll use when you've call APIs upfront vs when it's called based on user action? 5. What goes in hooks for you? (Intentional open ended question) 6. Why props is needed to be immutable? 7. What is the difference between controlled and uncontrolled component? ----------------------------------------------------------------------------------------------------------------- I'm a Senior Full Stack Engineer and recently just gave an interview for hiring a new dev on our team 💀 Some example general questions: 11. Are you familiar with the rules of hooks in React? 12. How would one optimise the performance of React contexts to reduce rerenders? 13. How do you ensure that a component can be unit test...

ReactJS: How and when to force a React component to re-render

Image
What is force re-rendering? Force re-rendering in React is like pressing the refresh button on a webpage, even when the page seems just fine. In React, it means telling a component to update and redraw itself, even if nothing has really changed in the data (stat/props) it uses. Although React is usually good at knowing when it is time to update a component, there are moments when you want to take the reins and tell it to refresh a certain part of the codebase. In this article, we will explore this in more detail. Understanding React’s rendering behavior Let’s take a closer look at how React’s rendering process works by default. To understand when and why you might need to nudge React into re-rendering, you need to get familiar with its underlying architecture. At the heart of  React’s rendering  magic lies the Virtual DOM. Imagine it as a clone of the actual DOM, the structure of your webpage. React uses this Virtual DOM to figure out what needs to be updated when your data ch...