Exercise: useImperativeHandle
by Tomas Trescak· React Hooks

0 / 1820 XP

1. Coding Exercise: Build a Controlled Dropdown

Objective

Create a Dropdown component that:

  1. Allows the parent to open and close the dropdown programmatically.
  2. Provides a method to check if the dropdown is open.

Tasks

  1. Implement the open, close, and isOpen methods in the Dropdown component.
  2. Test the methods by interacting with the buttons in the parent component.
  3. Ensure that the dropdown closes properly and displays its content when open.
1. CODING EXERCISE: BUILD A CONTROLLED DROPDOWN OBJECTIVE Create a Dropdown component that: 1. Allows the parent to open and close the dropdown programmatically. 2. Provides a method to check if the dropdown is open. TASKS 1. Implement the open, close, and isOpen methods in the Dropdown component. 2. Test the methods by interacting with the buttons in the parent component. 3. Ensure that the dropdown closes properly and displays its content when open.

Discuss with Others
Ask questions, share your thoughts, and discuss with other learners

Join the discussion to ask questions, share your thoughts, and discuss with other learners
Loading...
Ready ...
Content Locked
This content is only available to registered users.
Please register at the the home page.
Setup
React Fundamentals
10 points
Next.js
10 points
Advanced React
Databases
10 points
React Hooks
Authentication and Authorisation
10 points
APIs
CI/CD and DevOps
Testing React
Advanced Topics