import React, { useState, useEffect } from 'react'; const MyGroups = () => { const [state, setState] = useState({ MyGroups: [ { id: 1, group_title: 'TJ', }, ], }); const callAPI = () => { fetch(`${process.env.REACT_APP_API_ENDPOINT}/groups/`) .then((response) => response.json()) .then((data) => { if (data !== undefined) { setState(data); } }); }; useEffect(() => { callAPI(); }, []); return (

My Groups

Create Group


{state.MyGroups.map((group, index) => { let background; if (index % 2 === 0) { background = '#F1EAE8'; } else { background = '#FFFFFF'; } return (
{group.group_title}
); })}
); }; export default MyGroups;