import { useCallback, useState } from 'react'; import { post } from './api'; import UIButton from './UIButton'; import UILink from './UILink'; import UISecondaryBox from './UISecondaryBox'; import UITextInput from './UITextInput'; export default function GroupCreator() { const [name, setName] = useState(''); const [creationSuccessful, setCreationSuccessful] = useState(null); const [createdGroupId, setCreatedGroupId] = useState(0); const createGroup = useCallback(() => { post('/groups', { name, }) .then((res) => res.json()) .then(({ id }) => { setCreationSuccessful(true); setCreatedGroupId(id); }); }, [name]); return (

Create Group

Name Create group {creationSuccessful !== null && (creationSuccessful ? ( {name} {' '} has been created. ) : ( For some reason, {name} could not be created. ))}
); }