Assignment-12
Assignment-12
Scenario: At LaunchDarkly, you're working on a dashboard that displays a list of active users. The
data for the users is fetched from an API, and you need to handle this using useEffect. In addition,
you need to handle side effects such as setting up timers or event listeners, and cleaning them up
when the component is unmounted.
1. Fetches user data from a mock API when the component mounts.
3. Updates the state with the fetched data and displays it in the UI.
4. Uses useEffect to fetch the data only when the component is first mounted.
Assignment Tasks:
cd react-user-dashboard
npm install
o Add a timer in the UserList component that updates the document's title to show
the number of users fetched every 5 seconds, but make sure to clean it up when the
component unmounts.
4. Bonus (Optional):
o Add a search functionality to filter the list of users by name. You can create a search
input field and filter the displayed users by their name as the user types.
Submission:
1. src/App.jsx: The main file where you initialize and render the UserList component.
2. src/UserList.jsx: The component that fetches and displays user data using useEffect.
o How did you handle side effects (such as the timer) with useEffect?
o What challenges did you face and how did you solve them?
Learning Outcomes:
Learn how to use the useEffect hook to handle side effects such as data fetching and timers.
Understand how to clean up side effects when a component unmounts to avoid memory
leaks.
Improve your skills in managing state and side effects, which are essential for building
interactive and performant applications at LaunchDarkly.