Answers for "show and hide div based on radio button click react"

0

show and hide div based on radio button click react

import React from "react";

function Radio () {
  const [status, setStatus] = React.useState(0) // 0: no show, 1: show yes, 2: show no.

  const radioHandler = (status) => {
    setStatus(status);
  };

  return (
    <>
      <input type="radio" name="release" checked={status === 1} onClick={(e) => radioHandler(1)} />
      <input type="radio" name="release" checked={status === 2} onClick={(e) => radioHandler(2)} />
      {status === 1 && drawYesContent()}
      {status === 2 && drawNoContent()}
    </>
  );
}

export default Radio;
Posted by: Guest on September-21-2021

Code answers related to "show and hide div based on radio button click react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language