PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

React · Theory

Multiple Checkboxes in React

← All stacks

Theory

49/94

Multiple Checkboxes in React

Several checkboxes: store an array (or Set) of selected values. checked={on.includes(name)} onChange toggles membership. Don’t make useState(false) twenty times for a dynamic list. That’s the whole pattern.

Multiple Checkboxes in React — react starts checked. Tick Java → Java,React. State is an array of names.

Exam tip

Array of selected ids, not N booleans.

Example

// Checkboxes
import { useState } from "react";

const ALL = ["Java", "Python", "React"];

export default function Skills() {
  const [on, setOn] = useState(["React"]);
  function toggle(name) {
    setOn((s) => (s.includes(name) ? s.filter((x) => x !== name) : [...s, name]));
  }
  return ALL.map((name) => (
    <label key={name}>
      <input type="checkbox" checked={on.includes(name)} onChange={() => toggle(name)} />
      {name}
    </label>
  ));
}

Multiple Checkboxes in React — react starts checked. Tick Java → Java,React. State is an array of names.

Short notes

  • DefState : array of ids/names.
  • RuleChecked : includes().
  • RememberToggle : add or filter out.

Questions

1

Explain Multiple Checkboxes as if you are teaching a junior — definition, then one tiny UI.

2

Write 5–10 lines that use Multiple Checkboxes and say what the UI does.

3

What mistake do freshers make with Multiple Checkboxes?

Previous← Axios DELETE in ReactNextReact Icons →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.