Infosys
Interview Questions and Answers
Q1. Explain about hooks and when useRef hook is used
Hooks are functions that let you use state and other React features in functional components. useRef hook is used to persist a value between renders without causing a re-render.
Hooks are introduced in React 16.8 to allow state and lifecycle features in functional components.
useRef hook is used to persist a mutable value that won't trigger a re-render when changed.
It is commonly used to access DOM elements or store mutable values in functional components.
Example: const inputRe...read more
Q2. What are Higher order components?
Higher order components are functions that take a component and return a new component with additional functionality.
Higher order components allow code reuse and logic sharing between components.
They are commonly used for adding props, state, or lifecycle methods to components.
Example: withAuth HOC can add authentication logic to a component.
Q3. How do you maintain code quality
Code quality is maintained through code reviews, automated testing, coding standards, and continuous integration.
Regular code reviews by peers to catch errors and ensure best practices are followed
Implementing automated testing to catch bugs early in the development process
Enforcing coding standards and guidelines to maintain consistency and readability
Utilizing continuous integration tools to automate the build and testing process
Q4. What is lexical scope
Lexical scope refers to the visibility of variables within a specific block of code.
Variables declared inside a function are only accessible within that function's scope.
Nested functions have access to variables declared in their outer function's scope.
Lexical scoping allows for closures, where inner functions retain access to outer function's variables even after the outer function has finished executing.
Q5. Explain closusers and currying
Closures are functions that have access to their own scope and the scope of their outer function. Currying is the process of converting a function that takes multiple arguments into a sequence of functions that each take a single argument.
Closures allow functions to retain access to variables from their containing scope even after the outer function has finished executing.
Currying allows for partial application of a function, where some arguments are provided and the function...read more
Q6. Component life cycle in react
Component life cycle in React refers to the series of methods that are invoked at different stages of a component's existence.
Mounting: constructor, render, componentDidMount
Updating: render, componentDidUpdate
Unmounting: componentWillUnmount
Reviews
Interviews
Salaries
Users/Month