title: How can I handle the state of a checkbox in React
body: <p>I am trying to use a checkbox component in my react app and change the state when it is clicked. I keep getting infinite loop too many re-renders.</p>
  <pre><code>const [landlord, setLandlord] = useState(false)
  </code></pre>
  <pre><code>return (
  &lt;form class=&quot;form&quot; onSubmit={handleSubmit}&gt;
  
  &lt;Form.Group controlId=&quot;formBasicCheckbox&quot;&gt;
  &lt;Form.Check type=&quot;checkbox&quot; label=&quot;Are you a landlord?&quot; value={landlord} defaultChecked={false} checked={setLandlord(true)} /&gt; &lt;/Form.Group&gt;
  
  &lt;/form&gt;
  )
  </code></pre>
  <p>Any idea why this is failing.</p>