/lab-react-toggle

Learn to use React state and event handlers

Primary LanguageHTML

React Toggle Boards Lab

Toggle Boards Exercise

In this lab you're given starter that displays three boards with borders and a toggle button. Your task is to fill in the code that will make the next board become active (have a green border), when the toggle button is clicked. A description of the behavior is below

  • Initially, the first board is active and has a green border.
  • When you press the toggle button, the second board should be active, and the first one should be inactive.
  • When you reach the last board, and you press the toggle button, the first one should become active again.
  • For a working solution see: https://cunytechprep.github.io/lab-react-toggle-solution/

To start off and understand the desired toggle effect, try changing let isSelected = ii === 0; to let isSelected = ii === 1;

Tasks

  • change the app to render 5 boards
  • add state to track current selection
  • add an event handler for the toggle button

To submit

  • Make a fork of this repository
  • Clone your own fork
  • Solve the lab
    • to get started run npm install once to install the packages
    • to start the react app install npm start
  • Commit and push your code to your forked repository
  • Make a pull request back to this repository
    • Mention your Instructor and TA's names in your pull request message

Credit

This lab is based on and a React 18 / ES6 update to the excellent tutorial found at: https://buildwithreact.com/