One-liner React.js Interview Questions and Their Answers
One-liner React.js Interview Questions and Their Answers
What is JSX?
State is managed within the component, props are passed to the component.
By diffing the virtual DOM and applying changes to the real DOM.
A special function that lets you use state and other React features in functional components.
useEffect can be used in functional components, while componentDidMount is used in class components.
A way to pass data through the component tree without passing props down manually.
By using React.createContext().
A function that takes a component and returns a new component with added functionality.
A component that does a shallow comparison of props and state to decide if it should re-render.
What is Redux?
Single source of truth, state is read-only, and changes are made with pure functions.
A pure function that returns the new state based on the action.
Redux is more powerful and suitable for large applications; Context API is simpler and suitable for smaller apps.
redux-thunk.
What is redux-thunk used for?
useState is suitable for simpler state, useReducer is better for complex state logic.
A component that gets its value from state and updates via events.
A component that maintains its own state and updates via refs.
Breaking down the app into smaller chunks to improve load times.
A way to group multiple elements without adding extra nodes to the DOM.
Fragment does not add an extra element to the DOM, div does.
The process of updating the DOM based on changes in the virtual DOM.
What is ReactDOM.createPortal?
A method to render a component outside its parent DOM hierarchy.
By creating a function that uses React hooks and follows the naming convention use.
Anything that can be rendered in React, including elements, strings, and fragments.
What is React.StrictMode?
Controlled components are managed by React state, uncontrolled components manage their own state.
By using this.setState.
What is PureComponent?
To create a context object for passing data through the component tree.
A package that provides DOM-specific methods for rendering and updating the DOM.
How do you handle forms in React?
- A browser extension that allows inspection of React component hierarchies in the Chrome and Firefox Developer Tools.
@DimpleKumari
Forming a network of fantastic coders.