Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
How to set default radio button according to Json array Object checking condition

enter image description here

ReactJs Form Data should select json : if array object access.value === true then default select that radio button and can change it if i change

should work like below image : means set the radio button according to access access.value === true and change is if i change the radio button

and get is submit if i click down submit button and clear if i press cancel button

Required : TO set the value use hooks usestate

const data = [
{
  id: 1,
  name: data1,
  access: [
    { name: 'type1', value: false },
    { name: 'type2', value: true },
    { name: 'type3', value: false }
  ]
},
{
  id: 2,
  name: data12,
  access: [
    { name: 'type1', value: false },
    { name: 'type2', value: true },
    { name: 'type3', value: false }
  ]
},
{
  id: 3,
  name: data13,
  access: [
    { name: 'type1', value: true },
    { name: 'type2', value: false },
    { name: 'type3', value: false }
  ]
}
]

const [data, setData] = useState({});
const handleChange = (event) => {
const { name, value } = event.target;
setdata((state) => ({ ...state, [name]: value }));
};


return(
   {data[0].access.map((access) => (
                <RadioGroup
                  row
                  name={data.name}
                  value={[data.name]}
                  onChange={handleChange}
                >
                  <TableCell
                  >
                    <FormControlLabel
                      value={
                        access.name
                      }
                      control={<Radio />}
                      label=""
                    />
                  </TableCell>
                </RadioGroup>
              ))}
  )
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!