I have a parent component that fetches data and stores it into useState which then gets passed into a child component as a prop.
When that child component gets rendered, I store that prop data into useState which I try and then iterate over with a map or forEach function but I get cannot read property of undefined errors
when checking React Dev tools, the array that gets passed from Parent to child exists so im not too sure what im doing wrong.
Parent Component:
const DisplayOpenIncidents = () => {
  const [data, setData] = useState([]);
  const [loading, setLoading] = useState(true);
  useEffect(() => {
    const incidents = FetchIncidents();
    incidents.then((incidents) => {
      setData(incidents);
      setLoading(false);
    });
  }, []);
  return (
    <AccordionExample data={data} />
  );
};
Child Component:
const AccordionExample = (props) => {
  const [test, setTest] = useState(props.data);
  useEffect(() => {
    console.log(props.data); // Displays array
    setTest(props.data);
  }, [props]);
  return (
    <Accordion defaultActiveKey="0">
      <Card>
        <Accordion.Toggle as={Card.Header} eventKey="0">
          TITLE
        </Accordion.Toggle>
        <Accordion.Collapse eventKey="0">
          <Card.Body>
            {test.forEach((test) => {
              console.log(test);
            })}
          </Card.Body>
        </Accordion.Collapse>
      </Card>
    </Accordion>
  );
};
TIA
testinside a useEffect?