WIP: Basic Jodel Application
This commit is contained in:
27
src/components/NewPostForm.js
Normal file
27
src/components/NewPostForm.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import React, { useState } from 'react';
|
||||
|
||||
const NewPostForm = ({ addPost }) => {
|
||||
const [text, setText] = useState('');
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
if (text.trim()) {
|
||||
addPost(text);
|
||||
setText('');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<form className="new-post-form" onSubmit={handleSubmit}>
|
||||
<input
|
||||
type="text"
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
placeholder="Schreibe einen neuen Jodel..."
|
||||
/>
|
||||
<button type="submit">Posten</button>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
||||
export default NewPostForm;
|
||||
Reference in New Issue
Block a user