These interview questions are going to help you prepare for your next interview. Go through these questions once before your interview and land your dream job soon.
What is children prop?
Children prop is used to access the data put between opening & closing tag of component. To access children we can use this.prop.children
Why react uses className instead of class attribute?
Class is a reserved keyword in javascript that is why to react uses className instead of class.
What is a higher order component in React?
A higher-order component is a component that takes a component and returns a new component.
Where should we make an ajax call to fetch the data from API and render in the component?
We should make AJAX call on componentDidMount() lifecycle method. This method gets executed when the component loads into the DOM first time. In this way, we can have our data displayed in the render method.
Explain the use of Babel in React?
Babel is a transpiler that compiles JSX code into regular javascript.
What is webpack?
Webpack is a static module bundler, it takes javascript code, CSS, Modules, Images of the application, and packages together to be easily used inside the web browser.
How to prevent the default behaviour in event callback in React?
Simply call e.preventDefault() on the event passed in the callback function.
How we can prevent a component from rendering?
By returning null from the component render method prevents a component from rendering.
What are PropTypes in React?
PropTypes help React identify the types of props passed to the component.
What is ReactDOM?
ReactDOM is a top-level React API to render a react element into the DOM with the help of the ReactDOM.render() method.
What is React Context?
React Context is an API that allows to pass data down through a tree of components without having to pass props to each component in the tree.
How does React prevent injection attacks?
React DOM escapes any values embedded in JSX before rendering them into the DOM.
What does component mounting means in React?
Component Mounting means the corresponding element has been created into the DOM.
Explain error boundaries in React?
Error boundary helps to log errors and display a fallback UI in case of an error. Error boundary component implements getDerivedStateFromError & componentDidCatch methods.
What is the use of empty tags <> </> ?
Empty tags are used to create Fragments in React.
Subscribe to our Youtube channel for more videos :