import { Card, Button, Input, Row, Col } from 'antd'; import React, { useState, useCallback } from 'react'; import { usePush } from 'tipple'; export const AddPost = () => { const [body, setBody] = useState({ author: 'user', title: '' }); const [response, addPost, clearResponse] = usePush('/posts', { domains: ['posts'], fetchOptions: { method: 'POST', body: JSON.stringify(body) }, }); const handleInput = useCallback( (e: any) => setBody({ ...body, title: e.target.value }), [body] ); if (response.data !== undefined) { clearResponse(); setBody({ author: 'user', title: '' }); } const handleKeyDown = useCallback( event => { if (event.key === 'Enter') { addPost(); } }, [addPost] ); return ( ); };