Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PostsSection(props) {
- const dispatch = useDispatch();
- const name = useSelector(selectName);
- const [text, setText] = useState('');
- const handleClick = (e) => {
- e.preventDefault();
- if(text !== '') {
- dispatch(createPost({
- author: name,
- text: text
- }));
- setText('');
- }
- };
- return (
- <div>
- <div>
- <textarea
- value={text}
- onChange={(e) => setText(e.target.value)}
- />
- <button onClick={handleClick}>Post</button>
- </div>
- </div>
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement