React Interview Questions and Answers

How virtual dom works in react

Functional component returns the react Element (Object) with below properties.
  • type
  • key
  • ref
  • props
props is another object with property children. React fiber is used for rendering - non block rendering.

//You can print the component to see how the object looks like
let c1 = <main>hello</main>;
console.log(c1);

How to add image in react


import img1 from './img1.jpeg'; 
<img src={img1} />

How to access state from another component in react

You can use redux or combination of useContext and useReducer hooks.

How to avoid prop drilling in react

Prop drilling can be avoided by using useContext hook.

How to add event listener in react

You can add event listeners using useEffect hook. Do not forget to add empty array as second argument of useEffect function. Also remove listener in function returned from useEffect.

How to add background image in react

This is similar to img tag discussed above.

How to add css in react

Please check this CSS in react

How to access public folder in react

Put images or other files in public folder and then you can access it like ./

How to add fonts in react

Add fonts inside head tag in index.html

How to await setstate in react

How to add to state array in react

How to build and deploy in react

How to break up components in react

How to bold text in react

How to build for production in react

How to blur input in react

How to break line in react

useLayoutEffet vs useEffect

How to build project in react

How to bind this in react

How to bind function in react

How to copy to clipboard in react

How to change background color in react

How to call a function in another component in react

How to create a component in react

How to clear input after submit in react

How to cache data in react

How to call api in react

How to check if user is logged in in react

How to change state of another component in react

How to check if component is rendered in react

How to download a file in react

How to debug in react

How to display image in react

How to disable a button in react

How to deploy in react

How to detect page refresh in react

How to delete element from array in react

How to destroy component in react

How to delay render in react

How to detect mobile in react

How to export component in react

How to extend a component in react

How to export a function in react

How to enable cors in react

How to extend functional component in react

How to export multiple functions in react

How to export functional component in react

How to edit form in react

How to escape in react

How to force rerender in react

How to fetch data from api in react

How to focus an element in react

How to filter array in react

How to find memory leak in react

How to force refresh page in react

How to format date in react

How to fetch data in react

How to filter data in react

How to forward ref in react

How to get url params in react

How to get input value in react

How to get current url in react

How to get data from api in react

How to get element by id in react

How to generate unique keys in react

How to go to another page in react

How to get id from url in react

How to get previous url in react

How to go back to previous page in react

How to hide a component in react

How to hide api key in react

How to handle undefined props in react

How to have multiple pages in react

How to handle forms in react

How to handle api errors in react

How to handle errors in react

How to handle promise in react

How to hide scrollbar in react

How to hide element in react

How to import css in react

How to import image in react

How to import svg in react

How to import component in react

How to install in react

How to import json file in react

How to insert image in react

How to improve performance in react

How to import image from public in react

How to import fonts in react

How to store jwt token in react

How to import json file in react

How to read json file in react

How to import js file in react

How to use jquery in react

How to parse json in react

How to display json in react

How to import js in react

How to know which element was clicked in react

How to keep state in react

How to know which dependency changed in react

How to know if mobile in react

How to know what caused rerender in react

How to know why rerender in react

How to know if props changed in react

How to know in react version

How to loop through array in react

How to lift state up in react

How to link to another page in react

How to load image in react

How to layout components in react

How to lazy load images in react

How to listen to state change in react

How to log to console in react

How to load svg in react

How to make api calls in react

How to make a drop down menu in react

How to make a search bar in react

How to make a modal in react

How to make multiple pages in react

How to map an array of objects in react

How to map an object in react

How to make a button in react

How to mount a component in react

How to make a table in react

How to navigate to another page in react

How to name components in react

How to nest components in react

How to create new project in react

How to navigate using router in react

How to organize components in react

How to open link in new tab in react

How to override css in react

How to open modal in react

How to organize api calls in react

How to organize imports in react

How to organize tests in react

How to overlap components in react

How to add onclick event in react

How to pass props in react

How to pass data from child to parent in react

How to pass props to child in react

How to pass component as prop in react

How to prevent rerender in react

How to pass data between components in react

How to pass function as prop in react

How to pass props from child to parent in react

How to pass multiple props in react

How to pass ref to child in react

How to get query params in react

How to get query string in react

How to respond to query letter in react

What is query usemutation in react

How to redirect to another page in react

How to refresh page in react

How to rerender a component in react

How to refresh a component in react

How to render html string in react

How to redirect in react

How to reset state in react

How to run build locally in react

How to remove item from array in react

How to style components in react

How to send data from child to parent in react

How to stop re render in react

How to setstate in react

How to scroll to element in react

How to store jwt token in react

How to share state between components in react

How to set background image in react

How to structure components in react

How to test custom hooks in react

How to trigger rerender in react

How to test useeffect in react

How to test components in react

How to throw error in react

How to trigger useeffect in react

How to tell if mobile in react

How to test function inside component in react

How to test usestate in react

How to test error boundary in react

How to use context in react

How to unmount component in react

How to use props in react

How to update state in react

How to update context in react

How to use environment variables in react

How to use svg in react

How to use ref in react

How to use useeffect in react

How to use in react

How to validate input in react

How to validate form in react

How to get value from input in react

How to get value from select in react

How to check version in react

How to wait for setstate in react

How to wait for promise in react

How to write unit tests in react

How to wrap a component in react

How to write inline style in react

How to write a hook in react

How to wrap text in react

How to wait in react

How to write a function in react

How to prevent xss in react

How to parse xml in react

How to use xmlhttprequest in react

How to respond to How's your day in react

How to use z index in react

zoom image on hover in react



Web development and Automation testing

solutions delivered!!