score:0

Accepted answer
handleAddMonth = (newValue) => {
    const newArray = [ ...validMonths2019 ];
    newArray.push(newValue);
    setValidMonths2019(newArray);
}

score:0

const ParentComponent = () => {
  const [validMonths2019, setValidMonths] = useState([])

  function handleCheck (val) {
    const newValidMonths = [...validMonths2019] // copies state so that it can be worked with before updating the state using the set method
    if (!validMonths2019.includes(val)) {
      newValidMonths.push(val)
      setValidMonths(newValidMonths)
    }
    else { // This is to remove it from state incase the user un-checks the checkbox
      newValidMonths.filter(v => v !== val)
      setValidMonths(newValidMonths)
    }
  }

  ...

  return (
    <>
      <Form.Check label='January 2019' id="jan19" checked={validMonths2019.includes('01')} onChange={() => handleCheck('01')} />
      <Form.Check label='February 2019' id='feb19' checked={validMonths2019.includes('02')} onChange={() => handleCheck('02)} />
    </>
  )
}

score:0

var validMonths2019 = [];
function handleCheck (event) {
    // create the array with the valid months for 2019
    if (event.target.id === 'jan19' && event.target.checked)    validMonths2019.push('01')
    if (event.target.id === 'feb19' && event.target.checked) validMonths2019.push('02')
}

Related Query

More Query from same tag