React Portals and Refs Quiz

Create an account and save your quiz results

OR

Question 1/15

How do you create a portal in a React application?
const modalRoot = document.getElementById('modal-root');

function Modal({ children }) {
  return ReactDOM.createPortal(
    children,
    modalRoot
  );
}

Select your answer

Your Results

You did not answer any questions correctly.

Your Answers

Question 1/15
🙁 Your answer was incorrect
How do you create a portal in a React application?
const modalRoot = document.getElementById('modal-root');

function Modal({ children }) {
  return ReactDOM.createPortal(
    children,
    modalRoot
  );
}

Available answers

Question 2/15
🙁 Your answer was incorrect
Should refs be used to expose component functions as a public API?

Available answers

Question 3/15
🙁 Your answer was incorrect
What is required for a child functional component to handle a forwarded ref?

Available answers

Question 4/15
🙁 Your answer was incorrect
What is the main difference between <code>React.createRef</code> and <code>React.useRef</code>?

Available answers

Question 5/15
🙁 Your answer was incorrect
How does React handle cleanup for refs during unmounting of the component?

Available answers

Question 6/15
🙁 Your answer was incorrect
What is a common limitation of React portals?

Available answers

Question 7/15
🙁 Your answer was incorrect
Can a React component be mounted into multiple portals simultaneously?

Available answers

Question 8/15
🙁 Your answer was incorrect
What is a primary use case of React portals?

Available answers

Question 9/15
🙁 Your answer was incorrect
Why might you use the <code>useImperativeHandle</code> hook with <code>forwardRef</code>?

Available answers

Question 10/15
🙁 Your answer was incorrect
How do portals handle propagation of parent CSS styles?

Available answers

Question 11/15
🙁 Your answer was incorrect
What is a scenario where using refs is preferred over component state?

Available answers

Question 12/15
🙁 Your answer was incorrect
When using <code>useImperativeHandle</code>, what is passed to the hook to expose methods to the parent component?

Available answers

Question 13/15
🙁 Your answer was incorrect
Can a functional component use multiple refs for different purposes?

Available answers

Question 14/15
🙁 Your answer was incorrect
Which DOM event does not automatically propagate through React portals?

Available answers

Question 15/15
🙁 Your answer was incorrect
Which of the following statements about React refs is true?

Available answers